使用 jq 处理 json 文件的最佳实践

发布时间:2023年12月25日
  1. 使用 jq 格式化 json 文本后再存入 json 文件,但不回显 json 内容
jq . << EOF > example.json
[{
  "Classification": "hdfs-site",
  "Properties": {"dfs.replication": "1"}
}]
EOF
cat example.json
  1. 使用 jq 格式化 json 文本后再存入 json 文件,同时回显 json 内容(无 jq 语法着色)
jq . << EOF | tee example.json | jq
[{
  "Classification": "hdfs-site",
  "Properties": {"dfs.replication": "1"}
}]
EOF
cat example.json
  1. 使用 jq 格式化 json 文本后再存入 json 文件,同时回显 json 内容(有 jq 语法着色)
jq . << EOF | tee example.json | jq
[{
  "Classification": "hdfs-site",
  "Properties": {"dfs.replication": "1"}
}]
EOF
cat example.json
文章来源:https://blog.csdn.net/bluishglc/article/details/134926460
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。