Should be decoding and not encoding the JSON.