Find a key in JSON recursively with jQuery 1.4.2: $.inJSON
I needed a quick and dirty way to find a particular key's value in a JSON blob of relatively arbitrary structure. So I made the following jQuery 1.4.2 plugin, inJSON, along the same lines as $.inArray and $.grep
You can download it here: jquery.injson.js.
UPDATE: This plugin now has a project page on the jQuery plugin site.
Example of usage:
var zomg = {
"a": "b",
"c": {
"d": "e",
"a": [
{
"a": "barf"
},
{
"z": "biz"
}
]
}
};
$.inJSON(zomg, "a");
["b", [Object { a="barf"}, Object { z="biz"}], "barf"]
Feel free to comment if you have improvements or notice something's stupid in it.





Comments (0)
This thread has been closed from taking new comments.