I need to parse a Json file which have a lot of arrays.
This is the json source:
{
"iabVersion": "IAB_V2",
"categories": [{
"categories": [{
"categories": [{
"id": "1.1.1",
"name": "Commercial Trucks"
},
{
"id": "1.1.2",
"name": "Convertible"
},
{
"id": "1.1.3",
"name": "Coupe"
},
{
"id": "1.1.4",
"name": "Crossover"
},
{
"id": "1.1.5",
"name": "Hatchback"
},
{
"id": "1.1.6",
"name": "Microcar"
},
{
"id": "1.1.7",
"name": "Minivan"
},
{
"id": "1.1.8",
"name": "Off-Road Vehicles"
},
{
"id": "1.1.9",
"name": "Pickup Trucks"
},
{
"id": "1.1.10",
"name": "Sedan"
},
{
"id": "1.1.11",
"name": "Station Wagon"
},
{
"id": "1.1.12",
"name": "SUV"
},
{
"id": "1.1.13",
"name": "Van"
}],
"id": "1.1",
"name": "Auto Body Styles"
}
}
}
This is the json requred:
{
"id": "1.1.1",
"name": "Commercial Trucks"
}
{
"id": "1.1.2",
"name": "Convertible"
}
How can I parse it via jq?
10x:)
Assuming the JSON input has been corrected, the following jq filter seems to meet the requirements, such as they are:
.categories[].categories[].categories[]
This produces a stream of JSON objects, beginning:
{
"id": "1.1.1",
"name": "Commercial Trucks"
}
{
"id": "1.1.2",
"name": "Convertible"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With