Search for a key in JSON with jQuery: $.inJSON

Posted on August 28, 2010

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 powered by Disqus