【问题标题】:Extract the first object from a JSON array从 JSON 数组中提取第一个对象
【发布时间】:2020-06-02 01:01:55
【问题描述】:

输入:

[
  {
    "name": "John",
    "title": "Hello"
  }
]

输出:

{"name": "John","title": "Hello"}

【问题讨论】:

  • jq .[0] test.json

标签: json jq


【解决方案1】:

为了便于说明,以下假设是 bash 或类似 bash 的 shell:

$ jq -c first <<< '[ { "name": "John", "title": "Hello" } ]'
{"name":"John","title":"Hello"}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-06
    • 1970-01-01
    • 2019-03-22
    • 2019-09-20
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    相关资源
    最近更新 更多