jqueryjson

Using JQuery to manipulate JSON Object


Can we use JQuery functions to manipulate and search in JSON Object? Like if I have a big Object of type of array of this object:

Node 
{
    Name,
    Property1,
    Property2
}

Can I use jQuery function find to find a node with property Name as John? And similarly modify the contents as well?


I was actually looking for something like jLinq.


Solution

  • I think what you're looking for here is jLinq. It's like linq, but it's a jquery plugin.

    What you're asking would be something like:

    var matchingNodes = jlinq.from(data.Nodes).equals("Name", "John").select();
    

    If you want only the first match, try :

    var firstMatch = jlinq.from(data.Nodes).equals("Name", "John").first();