Though I may be diagnosing the root cause of an event, determining how many users it affected, or distilling timing logs in order to assess the perform
Fortunately in XML-land, we have wonderful technologies like XPath, XQuery, and XSLT to help us.
[...]
So this leads me to my question: are there any tools like this for JSON?
If you ask me, Xidel is exactly what you're looking for.
Xidel is a command line tool to download and extract data from HTML/XML pages or JSON-APIs, using CSS, XPath 3.0, XQuery 3.0, JSONiq or pattern templates. It can also create new or transformed XML/HTML/JSON documents.
Query:
xidel -s "input.json" \
-e '
$json/avg(
count(
(phoneNumber)()
)
)
'
or
xidel -s "input.json" -e '$json/avg(count((phoneNumber)()))'
Output:
2