I have a two part question (Very new to JSON)
- I need to build a json object out of attr 'data-id'. Can a JSON object be a single 'array' of numbers?
- I have got the code for this but I am struggling to build the JSON object, as follows:
code:
var displayed = {};
$('table#livefeed tr').each(function (i) {
var peopleID = $(this).attr("data-id");
//console.log("id: " + peopleID);
if(peopleID!="undefined") displayed += peopleID;
});
console.log(displayed);
However this does not work properly, I just end up with string of objects added together.
+operator is for strings(generally). Yourdisplayedin an object literal.