jquery - How to get JSON object values for a Particular key -


i using jqgrid grid data in json object format.

result :

{"key":"value1"},{"key":"value2", "id":"id"} 

i need values array "key".

var arr = [{"key":"value1"},{"key":"value2", "id":"id"}];  var anarrayofkeyvalues = [];    arr.foreach(function(ob, i) {    if("key" in ob) anarrayofkeyvalues.push(ob.key);  });    console.log(anarrayofkeyvalues); // ["value1", "value2"]


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -