CHanges json_decode to encode