javascript - Convert array of JSON object to a js map -
this additional question find value inside array of json object
i below array of json objects jsp
"titles":[ { "book3" : "bulletin 3" } , { "book1" : "bulletin 1" } , { "book2" : "bulletin 2" } ]
on js side, parsed , see array 3 objects.
now, want convert array of objects below js map.
newtitles["book3"] = "bulletin 3"; newtitles["book1"] = "bulletin 1"; newtitles["book2"] = "bulletin 2";
where newtitles
js object created via new object
command.
like this:
var newtitles = {}; titles.foreach(function(obj){ var key = object.keys(obj)[0]; newtitles[key] = obj[key]; });
Comments
Post a Comment