How to encode JSON embedded within JSON -
i have json string , 1 of fields text field. text field can contain text user enters in ui , if text enter json text, perhaps illustrate coding, need encode text not interpreted json within actual json structure sent server.
when json structure received server , gets decoded, need make sure embedded json gets decoded text, ends looking json in ui.
in effect, how escape embedded json string?
i'm doing similar, xml instead of json: on receiving malformed or otherwise non-processable data server returns error-structure containing information , original data. prevent client parsing corrupt data again it's base64 encoded on server.
so instead of sending
{ title : "my sample code", payload : "{ \"foo\" : \"bar\" }" }
consider sending
{ title : "my encoded sample code", payload : "eyaizm9viia6icjiyxiiih0=" }
Comments
Post a Comment