JSON looping problem

JSON looping problem

bradley32bradley32 Posts: 16Questions: 0Answers: 0
edited February 2011 in General
Hi guys,
I have a JSON source that I am calling from a web service. The JSON data is structured like so:

(I removed some of the JSON data to make is shorter, there are keys in the data that are not needed)

[code]
{
"searchAgentDocuments":{
"document":[
{
"createDate":"2010-07-12T20:30:31Z",
"documentId":"584493606",
"title":"Verizon Wireless Supports Lieberman-McCain First Responders Bill",
"matchWords":"Obama#",
"sourceName":"Yahoo! Finance Canada",
"sourceCountryName":"Canada"
},
{
"createDateDisplay":"07/12/10 13:30",
"documentId":"584493606",
"title":"47 workers walk picket line at Nanticoke steel plant",
"matchWords":"Obama#",
"sourceName":"The Sudbury Star",
"sourceCountryName":"Canada"
},
{
"createDateDisplay":"07/12/10 12:31",
"documentId":"584493606",
"title":"Perhaps a League of Democracies is best",
"matchWords":"Obama#",
"sourceName":"The Sudbury Star",
"sourceCountryName":"Canada"
}
]
}
}


[/code]

Here is the JS I have so far:

[code]
var docs = data.searchAgentDocuments.document;

for (var i = 0; i < docs.length; i++) {
var obj = docs[i];

var date = obj.createDate.split('T')[0];
var source = obj.sourceName;
var title = obj.title;
var keywords = obj.matchWords;
var country = obj.sourceCountryName;

var jsonData = ['', date, source, title, keywords, country];

};
[/code]

I am bringing in all of the data and parsing it, grabbing only the keys that I need and displaying them in the dataTable.

As of right now, I am getting the desired result but it is only bringing in the first record. I know its a looping problem but I am brain dead from the problem and need some expert help!

Thanks in advance!!

Replies

  • bradley32bradley32 Posts: 16Questions: 0Answers: 0
    Ugh...never mind...I figured it out : )

    Thanks anyway DT forum!
This discussion has been closed.