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

Multilayer CSV to filtered excel -

Listboxes in c# -

ios - Why must I define variables twice in the Header file? -