Updated JSON encoding and decoding methods