lindm Posted April 8, 2011 Share Posted April 8, 2011 Having problems creating the object structure. I want a structure like this: { "BFO": { "1": { "text1": "100", "text2": "200", "text3": "300" }, "2": { "text1": "400", "text2": "500", "text3": "600" } } } I am creating the object with an each iteration in jquery: function objects() { var BFO = new Object(); BFO["BFO"] = new Object(); $("tr").each(function(i) { BFO["BFO"][i] = new Object(); BFO["BFO"][i]["text1"]="test"; BFO["BFO"][i]["text2"]="test"; BFO["BFO"][i]["text3"]="test"; }); This generates: {"BFO":[{"text1":"test","text2":"test","text3":"test"},{"text1":"test","text2":"test","text3":"test"}]} } } Almost there but missing the 1, 2 etc and there are [] characters I don't need. Any help to complete appreciated. Link to comment https://forums.phpfreaks.com/topic/233144-create-object-problem/ Share on other sites More sharing options...
lindm Posted April 9, 2011 Author Share Posted April 9, 2011 Solved Link to comment https://forums.phpfreaks.com/topic/233144-create-object-problem/#findComment-1199295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.