Is it possible to wrap json in a json field like a string?
5 answers
JSON encoded stuff is just a string. If you want to embed json-in-json then the "internal" json must be json encoded.
eg.
$inner = {"foo":"bar"}
$outer = {"container":"{\"foo\":\"bar\"}"}
Now the internal json is no longer json. It's just a string that comes from kinda / sorta, which looks like JSON.
+4
source to share
It won't be great, but if you base64 encode the JSON payload, you can be sure it won't be parsed unexpectedly.
How to base64 encode with Javascript: http://www.webtoolkit.info/javascript-base64.html
{
"requestBody": "eyJmaWVsZDEiOiAxMTExMTEsImZpZWxkMiI6ICJzb21lVmFsdWUifQ=="
}
+1
source to share