Here is the top of my Json file. I am attempting to list two objects and its contents. I want to list the description and rtmp_url.
{
"features": [
{
"type": "Feature",
"geometry": {
"coordinates": [
-55.37174,
55.77598
],
"type": "Point"
},
"properties": {
"direction": "EB",
"mrm": 55,
"id": "555",
"jurisdiction": "test",
"route": "I-64",
"description": "test description",
"deviceid": "",
"rtmp_url": "test url1",
}
},
{
"type": "Feature",
"geometry": {
"coordinates": [
-55.36782,
55.77382
],
"type": "Point"
},
"properties": {
"direction": "WB",
"mrm": 44,
"id": "4444",
"jurisdiction": "test 2 jurisdiction",
"route": "I-64",
"description": "test 2 description",
"deviceid": "",
"rtmp_url": "test rtmp_url",
}
},
I want my output to be this. I just want to Grab "description": & "rtmp_url":
test description test url1
test 2 description test rtmp_url
This command
jq '.features[] | {description, rtmp_url }'
Give me this output
{
"description": null,
"rtmp_url": null
}
Assuming minor adjustments to your input to make it valid JSON,
jq -r '.features[].properties | "\(.description) \(.rtmp_url)"' input.json
produces
test description test url1
test 2 description test rtmp_url
as per the problem description.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.