Let\'s say I have an array like this
var myarray=[{\"id\":1234, \"listtext\":open, \"prop3\":value3 ,\"prop4\": value4},
{\"id\":1235, \"listtex
var myarray=[{"id":1234, "listtext":"open", "prop3":'value3' ,"prop4": 'value4'},
{"id":1235, "listtext":"closed", "prop3":'value3' ,"prop4": 'value4'},
{"id":1236, "listtext":"pending", "prop3":'value3' ,"prop4": 'value4'},
{"id":1237, "listtext":"open", "prop3":'value3' ,"prop4": 'value4'}];
var myObjects = []; // create an empty array to hold the converted objects.
// loop through the array to convert them one by one
myarray.forEach(function(element) {
var obj = {}; // create an empty object
obj[element.id] = element.listtext;
myObjects.push(obj); // add the object to the array
});
myObjects.forEach(function(object){
console.log(object);
});