I am looking for a way to loop through all of my SQL data that I have parsed into a JSON table and add a key to each item in an array.
Currently, I can loop through the data and concatenate it into a simple string like this:
var dbString ="";
for(i = 0; i < result.response.length; i++)
{
dbString += result.response[i].names;
}
Which results in something like:
var dbString = "James Michael Alfred....";
However, I would like to format it differently like so:
var dbString = {"James":1, "Michael":2, "Alfred":3, .....}
If anyone has any suggestions on how to achieve this, I would greatly appreciate it. Thank you!