Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.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
JQ-无法从Ubibot json提取值_Json_Jq - Fatal编程技术网

JQ-无法从Ubibot json提取值

JQ-无法从Ubibot json提取值,json,jq,Json,Jq,我有一个Ubibot ws-1,我试图从以下JSON中的last\u值中提取时间戳、温度、湿度、光照和电压 API JSON输出是 { "channel": { "channel_id": "1111", "name": "C-1111", "field1": "Temperature", "field2": "Humidity", "field3": "Light", "field4": "Voltage", "field5": "W

我有一个Ubibot ws-1,我试图从以下JSON中的
last\u值中提取时间戳、温度、湿度、光照和电压

API JSON输出是

{
  "channel": {
    "channel_id": "1111",
    "name": "C-1111",
    "field1": "Temperature",
    "field2": "Humidity",
    "field3": "Light",
    "field4": "Voltage",
    "field5": "WIFI RSSI",
    "field6": "Vibration Index",
    "field7": "Knocks",
    "field8": "External Temperature Probe",
    "field9": "Reed Sensor",
    "field10": null,
    "latitude": "1",
    "longitude": "1",
    "elevation": null,
    "created_at": "2019-02-05T05:16:43Z",
    "updated_at": "2019-02-05T06:11:38Z",
    "metadata": "{\"fn_dp\":900,\"fn_th\":300,\"fn_light\":300,\"fn_acc_act\":0,\"thres_acc_min\":0,\"fn_acc_tap1\":0,\"fn_acc_tap2\":0,\"fn_ext_t\":300,\"fn_battery\":7200,\"fn_485_th\":0,\"fn_485_sth\":0,\"net_mode\":0,\"no_net_fn\":1,\"cg_data_led\":1,\"wifi_mode\":1}",
    "tags": null,
    "public_flag": "false",
    "url": null,
    "description": null,
    "write_key": "1b0f2b31a6d522a376782a90f4be0270",
    "user_id": "9186F150-9203-492B-B31A-77077E15E461",
    "last_entry_id": "583",
    "last_entry_date": "2019-02-05T19:12:47Z",
    "usage": "96328",
    "device_id": "17a867e84624895f6dab0346a4cba8cfd8279298",
    "status": "{\"ssid\":\"hydra1\",\"status\":\"ssid=wifi,usb=1\",\"usb\":\"1\"}",
    "status_date": "1549393967",
    "last_ip": "nn.nn.nn.nnn",
    "channel_icon": null,
    "product_id": "ubibot-ws1",
    "plan_code": "ubibot_free",
    "plan_start": "2019-02-05T05:16:43Z",
    "plan_end": null,
    "bill_start": "2019-02-05T05:16:43Z",
    "bill_end": "2019-03-07T05:16:43Z",
    "traffic_out": "188763",
    "traffic_in": "33767",
    "full_dump": "0",
    "renew": null,
    "last_values": "{\"field1\":{\"value\":27.186996,\"created_at\":\"2019-02-05T19:12:39Z\"},\"field3\":{\"value\":10.37,\"created_at\":\"2019-02-05T19:12:39Z\"},\"field2\":{\"value\":29,\"created_at\":\"2019-02-05T19:12:39Z\"},\"field5\":{\"value\":-35,\"created_at\":\"2019-02-05T19:12:41Z\"},\"field4\":{\"value\":5,\"created_at\":\"2019-02-05T17:27:38Z\"}}",

  }
}
我的jq技能非常差。
.channel.last\u值。“\(.field1)
给了我
jq:error(at:0):无法为字符串“null”的字符串编制索引。


有人能帮我找到正确的jq吗?提前谢谢你,你需要先将
最后的值
解析为JSON值。为此,请使用
fromjson

jq '.channel.last_values|fromjson.field1' file

太好了-这很有效-非常感谢@oguzismall的帮助