JSONPath或其他类似XPath的JSON / Javascript实用程序;或Jquery JSON [英] JSONPath or other XPath like utility for JSON/Javascript; or Jquery JSON
问题描述
我一直在关注JSONPath,虽然看起来做得很好,但我想知道是否有人使用它并且可以对其可用性发表评论,还是可以推荐其他选择?什么真正光滑的是,如果有一个JQuery的插件做了这样的事情。我一直在搜索插件并空手而归。无论如何,在我花时间去了解JSONPath(其中有一些我不喜欢的方面)之前,或者在我重新发明轮子之前,我想我会看到是否有人对此有所了解......
I have been looking at JSONPath and though it seems pretty well done, I wonder if anyone has worked with it and can comment on its usability, or can recommend alternatives? What would be really slick is if there was a plugin for JQuery that did something like this. I have been searching the plugins and coming up empty handed. Anyway, before I spend time getting to know JSONPath (which has some aspects I am not keen on), or before I reinvent wheels, I thought I'd see if anyone had an angle on this...
为了让你知道我的意思,想象一下这个Javascript对象:
To give you an idea 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",
//...ok, you get it...
}
]
用Jquery选择器之类的东西来获取一些更深层次的对象会不会很棒?
Wouldn't it be great to get to of some of the deeper objects by something like Jquery selectors?
var banana=SomeUtility("Characters holding #Banana").get(0);
var leftHands=SomeUtility("Characters appendage[type=hand][side=left]").get();
(这可能有资格获得世界上最丰富的代码示例,但是嘿,我的孩子们只是看了这个。而我不能使用真实的例子,因为NDA ...)
(This may qualify for worlds corniest code example, but hey, my kids just watched this. And I can't use real example because of NDA...)
...而且,为了让它更有趣,如果我要创造这样的东西,任何人都会使用它?
...And, to make it more interesting, if I were to create such a thing, would anyone use it?
推荐答案
查看 JSON Select - 类似于JSON的CSS选择器。
Check out JSON Select - CSS-like selectors for JSON.
这篇关于JSONPath或其他类似XPath的JSON / Javascript实用程序;或Jquery JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!