i'll try simplify case:
offenses = {}; $(offensetableid).find('tr').each(function (rowindex, r) { // building json object named "offense" object // information table row. // console.log shows it's correct. typically have 3 rows // showing different information. // trying extend offenses constructed. $.extend(offenses, offense); }); // after i'm done i'm printing "offenses" json object, // expecting include added, if // $.extend multiple times - remembers last json // object $.extend'ed why? console.log(json.stringify(offenses));
this because objects must have unique keys. can't append new object existing object , expect useful. want array of objects.
offenses = []; $(offensetableid).find('tr').each(function (rowindex, r) { // building object named "offense" object // information table row. // console.log shows it's correct. typically have 3 rows // showing different information. // trying extend offenses constructed. offenses.push(offense); });
this result in array looks this:
[{name:'bob'},{name:'frank'}]
you can stringify json:
[{"name":"bob"},{"name":"frank"}]
Comments
Post a Comment