【问题标题】:jq parse issue with array [duplicate]jq解析数组问题[重复]
【发布时间】:2018-04-19 21:48:10
【问题描述】:

我正在使用 jq 来解析值但没有得到预期的结果,谁能给我建议 内容是

{
  "id": "8a9o0laf3ff0",
  "displayId": "8a0a",
  "author": {
    "name": "Rahul",
    "emailAddress": "donotreply@mail.com"
  },
  "authorTimestamp": 1524168139000,
  "message": "SD-90",
  "parents": [
    {
      "id": "8c1679f0813c",
      "displayId": "8c0f",
      "author": {
        "name": "Sahotay",
        "emailAddress": "donotreply@mail.com"
      },
      "authorTimestamp": 1523544887000,
      "message": "Fixing issues in SD-88",
      "parents": [
        {
          "id": "d022838cf4e6",
          "displayId": "d0a3"
        }
      ]
    }
  ],
  "properties": {
    "jira-key": [
      "SD-90"
    ]
  }
}

我想获取jira-key的值

jq '.properties' myjason.json
{
  "jira-key": [
    "SD-90"
  ]
}

但如果我使用.jira-key[] 则无法正常工作

【问题讨论】:

    标签: key jq


    【解决方案1】:

    你可以用这个

    jq '.properties["jira-key"]' test.json
    

    否则 jq 会将破折号解析为减法

    【讨论】:

      猜你喜欢
      • 2020-12-16
      • 1970-01-01
      • 1970-01-01
      • 2019-01-02
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多