3 ms·
XSLT and XPath is about the only reason I can see to use this. But, you know, how hard is: x.person.addresses[0].city? I guess XPath is easier when you pr
by ericmoritz 15y ago
XSLT and XPath is about the only reason I can see to use this. But, you know, how hard is:
x.person.addresses[0].city?
I guess XPath is easier when you probably have to do something like this:
JSONObject json = (JSONObject) JSONSerializer.toJSON( jsonTxt )
String city = json.getJSONObject("person").getJSONArray("addresses").getJSONObject(0).getJSONObject("city");
Or however you'd do it in Java.
- wulczer 15y agoThat's not hard, what's hard is //person[@alive="true"]/pets//dog[@hair="long"]/*/flea[@name]
- deleted 15y ago[deleted]
- catshirt 15y agostill, i think an xpath evaluator for json would have been the way to go here instead
- Stormbringer 15y agoYou appear to be confusing Java and Javascript. JSON stands for Javascript Object Notation. In Java the equivalent would simply be serialization. NB: if XSLT and XPath is the solution, you've already lost.
- gte910h 15y agoJSON is used for far far more than javascript these days. It's a far better communication protocol than XML for most things.