Ele*_*nor 3 bash json jq jsonlines
这是我的json:
[
{
"ReferringUrl": "N",
"OpenAccess": "0",
"ItmId": "1694738780"
},
{
"ReferringUrl": "L",
"OpenAccess": "1",
"ItmId": "1347809133"
}
]
Run Code Online (Sandbox Code Playgroud)
我希望它回到原始的json格式:
[{"ReferringUrl": "N","OpenAccess": "0","ItmId": "1694738780"},{"ReferringUrl": "L","OpenAccess": "1","ItmId": "1347809133"}]
Run Code Online (Sandbox Code Playgroud)
如何使用jq来做到这一点?:) 谢谢!
只需使用--compact-output/-c选项:
cat file | jq -c
Run Code Online (Sandbox Code Playgroud)
(或者,不滥用猫:jq -c '.' file)