jq用数组解析问题

时间:2018-04-19 21:48:11

标签: key jq

我正在使用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[]则无效

1 个答案:

答案 0 :(得分:0)

你可以用这个

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

否则jq将短划线解析为减法