我有一个很大的JSON文本,需要使用
进行解析jq --stream
但是,没有详尽的用例或博客可以理解这一点。
JSON结构如下:
{
"userActivities": {
"-----P9E3PJB5bTO1xrO": {
"aaid": "84dae6bd-cb3a-409c-9940-844f035b5fc7",
"callsign": "2day",
"deviceId": "1b771f137d1bc6ea",
"dow": "Thursday",
"downloadFlag": "N",
"email": "ckcafeandcatering@gmail.com",
"emailSha256": "6ab0992297a9478be9ae7ff26d811b1116c45a0c819ff1c9628c9b7ca4ec4129",
"event": "streamStop",
"firebaseUID": "anvlMojJFvQEvMXQW6GeRzLKCIA2",
"halfHourFull": "10h1",
"liveFlag": "Y",
"localDate": "1970-01-01",
"localHalfHour": 1,
"login": "google",
"minutesSinceMidnight": 601,
"quarterHourFull": "10q1",
"stationName": "2DayFM104.1"
},
"-GuGCJDEprMKczAMDUj8": {
"deviceId": "399a649c6cee6209",
"dow": "Thursday",
"downloadFlag": "N",
"event": "streamStart",
"halfHourFull": "18h1",
"liveFlag": "Y",
"localDate": "2009-01-01",
"localHalfHour": 1,
"minutesSinceMidnight": 1080,
"quarterHourFull": "18q1",
"stationName": "hit 105",
"streamListenMethod": "Headphones",
"timestampLocal": "2009-01-01T18:00:33.679+10:00",
"timestampUTC": "2009-01-01T08:00:33.679Z"
}
}
}
我想在localDate上放置一个过滤器,即仅选择localDate ='2009-01-01'的那些数组。
当前,我正在将JSON输入以下命令,它会提供所有数组。
jq -cn --stream 'fromstream(1|truncate_stream(inputs | select(.[0][] == "userActivities") | del(.[0][0])))'
如何放置过滤器?请提示。任何帮助将不胜感激。
答案 0 :(得分:0)
附加此过滤器:
select(.localDate == "2009-01-01")
因此,您修改后的命令将变为:
jq -cn --stream 'fromstream(1|truncate_stream(inputs | select(.[0][] == "userActivities") | del(.[0][0]))) | select(.localDate == "2009-01-01")'