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

using jq how to sort array of object

$
0
0

There is an array of json object, using jq how to check if an object exists if so returns the true else false

I tried this but getting error

cat fruits.json | jq '.fruits[]| sort_by(.version)'

I would like to sort by decending order and output the price of the most recent version.

{"fruits": [        {"name": "banana","color": "yellow","price": 0.51,"version": 1        },        {"name": "banana","color": "yellow","price": 0.52,"version": 2        }    ]}

Viewing all articles
Browse latest Browse all 657

Trending Articles



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