Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 如何使用jq从数组中提取字符串?_Json_Jq - Fatal编程技术网

Json 如何使用jq从数组中提取字符串?

Json 如何使用jq从数组中提取字符串?,json,jq,Json,Jq,如何使用jq从值数组中提取值“0.9212835072256392” { "resultType": "vector", "result": [ { "metric": {}, "value": [ 1608561506.684, "0.9212835072256392"

如何使用jq从
数组中提取值
“0.9212835072256392”

{
  "resultType": "vector",
    "result": [
      {
        "metric": {},
        "value": [
          1608561506.684,
          "0.9212835072256392"
        ]
      }
    ]
 }
我尝试了不同的解决方案,例如
jq'.result.value[1]'
。这给了我一条错误消息
jq:error(at:1):无法使用字符串“value”为数组编制索引
如果可以在
数组中使用硬编码索引,则可以使用:

.result[] | .value[1]


或者,根据建议,使用
.value[-1]
获取最后一个索引

.result[] | .value[-1]

或不带硬接线:
.result[]|.value[length-1]