Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

using jq want to parse array nested inside object. But the entire object gets duplicated in output

$
0
0

json ={"Country":"India","States": [{"Name":"TN","Cities":["city1","city2"]},{"Name":"KL","Cities":["city3","city4"]}]}

query = {country:.Country,states: .States | (foreach .[] as $item (0; {name:$item.Name,city:$item.Cities} ))}

output

{"country": "India","states": {"name": "TN","city": ["city1","city2"]}}{"country": "India", "states": {"name": "KL","city": ["city3","city4"]}}

dont want the country to be repeated two times. The main requirement is to change the key names. like city instead of Cities.


Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>