简体   繁体   English

jq'。' 使用jq将格式化的json文件恢复为原始json格式

[英]jq '.' formatted json file back to original json format using jq

Here is my json: 这是我的json:

[
 {
  "ReferringUrl": "N",
  "OpenAccess": "0",
  "ItmId": "1694738780"
 },
 {
  "ReferringUrl": "L",
  "OpenAccess": "1",
  "ItmId": "1347809133"
 }
]

I want it back to the original json format: 我希望它回到原始的json格式:

[{"ReferringUrl": "N","OpenAccess": "0","ItmId": "1694738780"},{"ReferringUrl": "L","OpenAccess": "1","ItmId": "1347809133"}]

How to use jq to do this? 如何使用jq来做到这一点? :) Thank you! :) 谢谢!

Just use the --compact-output / -c option: 只需使用--compact-output / -c选项:

cat file | jq -c

(or, without feline abuse: jq -c '.' file ) (或者,没有猫科动物滥用: jq -c '.' file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM