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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -