I looked at JSONPath, and although it looks pretty good, I wonder if anyone has worked with it and can comment on its usability or can recommend alternatives? Which would be very smooth if there was a jQuery plugin that did something like this. I searched for plugins and came up empty-handed. Anyway, before I spend time, I get to know JSONPath (which has some aspects that I'm not addicted to), or before I invent the wheels, I thought I'd see if anyone had a corner on this. ..
To give you an idea of ββwhat I mean, imagine this Javascript object:
var Characters=[ { id: "CuriousGeorge", species:"Monkey", mood: "curious", appendage: [ { type: "hand", side: "left", holding: [ { id: "Banana" } ] }, { type: "hand", side: "right", holding: [] }, { type: "foot", side: "left", holding: [] }, { type: "foot", side: "right", holding: [ { id: "YellowHat" }, { id: "Keys" } ] } ] }, { id: "ManInYellowHat", species: "Human", mood: "angry",
Wouldn't it be great to get to some deeper objects with something like jQuery selectors?
var banana=SomeUtility("Characters holding #Banana").get(0); var leftHands=SomeUtility("Characters appendage[type=hand][side=left]").get();
(This may pretend to be the most powerful code in the world, but, hey, my kids just watched it. And I can't use a real example because of the NDA ...)
... And to make it more interesting, if I created one, would someone use it?
json javascript jquery jsonpath
jlarson May 13, '09 at 16:39 2009-05-13 16:39
source share