I'm building a json array and I need the structure of the json data to look like the following example below. Specifically, I need "success": 1, and "result": [ ] to wrap around the objects in the array only ONCE. However, my code outputs the json string with {"success":1,"result":[{ objects }} before the start of each array.
here's my code in action. http://plnkr.co/edit/vziEecjJWUid2qtcJkp9?p=preview
view your console.log to see where it's looping through the "success": 1, and "result": [ ] at the start of each array.
example of what I need.
{
"success":1,
"result":[
{
"id":"01",
"title":"awesome title",
"url":"someurl.com",
"class":"event",
"start":"8:30 AM",
"startTime":"8:30 AM",
"endTime":"5:00 PM",
"EventDate":"5:00 PM"
},
{
"id":"01",
"title":"awesome title",
"url":"someurl.com",
"class":"event",
"start":"8:30 AM",
"startTime":"8:30 AM",
"endTime":"5:00 PM",
"EventDate":"5:00 PM"
}
]
}
My current json structure (no good):
{"success":1,"result":[{
"id":"01",
"title":"awesome title",
"url":"someurl.com",
"class":"event",
"start":"8:30 AM",
"startTime":"8:30 AM",
"endTime":"5:00 PM",
"EventDate":"5:00 PM"
}] }
{"success":1,"result":[{
"id":"01",
"title":"awesome title",
"url":"someurl.com",
"class":"event",
"start":"8:30 AM",
"startTime":"8:30 AM",
"endTime":"5:00 PM",
"EventDate":"5:00 PM"
}] }