エスケープされた json を jq で整形する
どういうことか
こういうエスケープされた json 部分を整形して表示したい
{
"a" : 1,
"b" : 2,
"c" : "{\"id\":\"hoge\",\"parent\":\"abc\"}\n"
}
解決法
fromjson
を使う。
$ pbpaste
{
"a" : 1,
"b" : 2,
"c" : "{\"id\":\"hoge\",\"parent\":\"abc\"}\n"
}
$ pbpaste | jq '.c | fromjson'
{
"id": "hoge",
"parent": "abc"
}
参考
Use jq to parse a JSON String - Stack Overflow
https://stackoverflow.com/questions/35154684/use-jq-to-parse-a-json-string
jq Manual (development version)
https://stedolan.github.io/jq/manual/
Author And Source
この問題について(エスケープされた json を jq で整形する), 我々は、より多くの情報をここで見つけました https://qiita.com/noid11/items/9716ac5b03b2b2f8be96著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .