javascript - Cut data from array of JSON objects -
javascript - Cut data from array of JSON objects -
i have array of json objects this:
[ { id: 841, when: 'date', who: 'asd', what: 'what', key1 : 'a key', key2 : 'a key' _id: 544034ab914ae3b9270545c1, __v: 0 }, { id: 841, when: 'date', who: 'asd', what: 'what', key1 : 'a key', key2 : 'a key' _id: 544034ab914ae3b9270545c1, __v: 0 } ]
i want cutting key1
, key2
from objects , want see this:
[ { id: 841, when: 'date', who: 'asd', what: 'what', _id: 544034ab914ae3b9270545c1, __v: 0 }, { id: 841, when: 'date', who: 'asd', what: 'what', _id: 544034ab914ae3b9270545c1, __v: 0 } ]
how can cutting keys , values?
my method not working. (pseudo) :
var new_array old_array.length delete old_array[i].key1 delete old_array[i].key2 new_array.push(old_array[i])
yourarray = yourarray.map(function(current, index, arr){ delete current.key1; delete current.key2; homecoming current; });
that should wish ;-)
hope helps, jan
javascript arrays json
Comments
Post a Comment