Fixing json encoding