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

How to get max value from JSON?

$
0
0

There is a json file like this:

[{"createdAt": 1548729542000,"platform": "foo"},{"createdAt": 1548759398000,"platform": "foo"},{"createdAt": 1548912360000,"platform": "foo"},{"createdAt": 1548904550000,"platform": "bar"}]

Now I want to get the max createdAt of foo platform? how to implement it by using jq?

jq '.[] | select(.platform=="foo") | .createdAt | max' foo.jsonjq: error (at <stdin>:17): number (1548729542000) and number (1548729542000) cannot be iterated overjq '.[] | select(.platform=="foo") | max_by(.createdAt)' foo.jsonjq: error (at <stdin>:17): Cannot index number with string "createdAt"exit status 5

Viewing all articles
Browse latest Browse all 524

Trending Articles



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