Best way to find whether a value exists in a JSON object in javascript?

ecmascript-5, javascript, json

Solution

Parse the JSON string with `JSON.parse` to get a JavaScript Object.

Use `in` operator to check the member existence

var jsObj = JSON.parse('{"p": 5}');
console.log(jsObj);
if ("p" in jsObj) {
    console.log("`p` exists");
}

Output

{ p: 5 }
`p` exists

Problem

I have a single level JSON to search through for the presence of a given value. Is there is a compact method provided in ecma5 for the same ?

Original source