How to convert embedded (quoted) json string to json
With jq
's fromjson
function:
Sample stuff.json
contents:
{
"stuff": "{\"date\":\"2018-01-08\"}"
}
jq -c '.stuff | fromjson' stuff.json
The output:
{"date":"2018-01-08"}
There is a raw
flag for this
-r output raw strings, not JSON texts;
jq -rc .stuff stuff.json
Output
{"date":"2018-01-08"}