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

jq '.' formatted json file back to original json format using jq

这是我的json:

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

我想把它恢复成原来的json格式:

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

如何使用jq来做到这一点? :) 谢谢!

只需使用 --compact-output / -c 选项:

cat file | jq -c

(或者,没有猫虐待:jq -c '.' file