News for hackers. Stuff that matters.
Re:Specifying JSON by jimbokun on Thursday May 19, 2016 @10:36AM (#11730520)
XPath, XSLT and XQuery are pretty awesome, in their special way.

Although stringly-typed XPath has the same problems as SQL, building complex queries through string concatenation. This is where JSON shines, because you usually just convert to a tree of your language's native data structures in one line and use your languages native facilities to traverse it from there.

Re:Specifying JSON by andyjohnson0 on Thursday May 19, 2016 @11:21AM (#11730888)
Is there an equivalent of xpath for searching/traversing in-memory js object graphs?
Re:Specifying JSON by kisstheblade on Thursday May 19, 2016 @01:17PM (#11731786)
Re:Specifying JSON by Chyzwar on Thursday May 19, 2016 @11:35AM (#11730977)
you can use chained map/reduce.

object.listOfItems .reduce((item) => item.type === 'car') .map((item) => item.name));

This is way more powerful than xpath.

Re:Specifying JSON by AlbertoGP on Thursday May 19, 2016 @02:41PM (#11732579)
Hi, I think that instead of "reduce((item) => item.type === 'car')" you actually meant "filter((item) => item.type === 'car')".
Re:Specifying JSON by arethuza on Thursday May 19, 2016 @12:47PM (#11731533)
What about things like axes in XPath?
Re:Specifying JSON by mhd on Thursday May 19, 2016 @11:57AM (#11731160)
Sometimes all you need is printf, not direct memory access to the character byte array.
Re:Specifying JSON by dschep on Thursday May 19, 2016 @02:16PM (#11732351)
There's JMESPath: http://jmespath.org/