I have a json like this:
json1 :
{
"field1": 111111,
"field2": "someValue"
}
How can I wrap it in "requestBody" field into json2 like a string?
json2 :
{
"requestBody": json1
}
Something like this:
{
"requestBody": "{"field1": 111111,"field2": "someValue"}"
}
JSON-encoded stuff is just a string. If you want to embed json-in-json, then the "inner" json has to be encoded into json itself.
e.g.
$inner = {"foo":"bar"}
$outer = {"container":"{\"foo\":\"bar\"}"}
Now the inner json isn't json anymore. It's just a string that happens to kinda/sorta look like JSON.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With