这个神秘的jq失败是什么?

时间:2016-11-06 23:26:53

标签: jq

我见过这个问题。我想这与特殊的char有关。我已经阅读了jq手册并引用了该字段,但仍然失败,我尝试使用/不使用括号

abc@uswest1aprod 13:49:59 ~
   $ cat test | jq .
{
  "bus_v320161103-12-00-44": {
    "aliases": {
      "bus_v3": {}
   },
    "mappings": {
      "business": {
        "dynamic": "strict",
        "_all": {
          "enabled": false
        }
      }
    }
  }
abc@uswest1aprod 13:52:33 ~
   $ cat test | jq ."bus_v320161103-12-00-44"
jq: error: null and number cannot be subtracted
abc@uswest1aprod 13:53:09 ~
   $ cat test | jq .["bus_v320161103-12-00-44"]
error: bus_v320161103 is not defined
.[bus_v320161103-12-00-44]  1 compile error

1 个答案:

答案 0 :(得分:1)

You need to quote your filter so it isn't interpreted by the shell...

$ jq '."bus_v320161103-12-00-44"' test

Without it, it's effectively being passed in like this:

.bus_v320161103-12-00-44

Which is accessing a field called bus_v320161103 and subtracting that by 12, then 00 then 44.

相关问题