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
Post a Comment