Unnesting json object -
my sample json is
"multilist": [ { "my_key" : "this key" }, { "my_text_box": "this text box" },
]
how convert {"my_key" : "this key"}, {my_text_box": "this text box"}, dynamically?
using jquery
your question doesn't make sense. asking convert 2 separate objects? string representation of 2 objects? else? can first two:
var objone = json.multilist[0]; var objtwo = json.multilist[1]; var objstr = json.stringify(json.multilist[0]) + ', ' + json.stringify(json.multilist[1]);
if want add of separate properties 1 object, can extend object in loop.
var obj = {}; json.multilist.foreach(function (elem) { (k in elem) { if (elem.hasownproperty(k)) { obj[k] = elem[k]; } } });
http://jsfiddle.net/explosionpills/t2xyd/
this makes no consideration overriding of properties in obj
.
Comments
Post a Comment