JQuery.getJSON () Don't parse all objects
I am using jQuery.getJSON function to parse a set of search results in Google Search Appliance. The Google Search Appliance has an xslt stylesheet that returns the results as JSON data which I have validated with JSONLint and Curious Concept JSON Formatter.
According to FireBug, the full result set is returned from XMLHTTPRequest, but I tried to dump the data (using jquery.dump.js) and it only parses the first result. He successfully retrieves all of the Google Search Protocol content, but he only sees one "R" object (or individual result).
Has anyone had a similar problem with jQuery.getJSON? I know he likes to fail if the JSON is invalid, but as I said, I checked the results with multiple validators and it should be good to go.
Edit: By clicking on this link you will see the JSON search results for the word "google": http://bigbird.uww.edu/search?client=json_frontend&proxystylesheet=json_frontend&proxyrefresh=1&output=xml_no_dtd&q=google
jQuery only fetches the first "R" object, although all "R" objects are siblings.
a source to share
You can try to make "getJSON" yourself with your own "jsonpCallback" function. If the response from the API you are calling looks like a comma-separated list of JSON expressions, then the auto-built callback will only see the first one.
In other words, if the API returns
{something: "foo", whatever:23}, {something: "bar", whatever, 32}
what will be in the script response block:
magicJqueryCallback({something: "foo", whatever:23}, {something: "bar", whatever, 32})
The jQuery callback is declared to have only one argument, which it assigns to the "data" element of the fake XHR object.
Alternatively, if you have control over what the XSLT code does, you can force it to wrap the answer list in a set of square brackets before it even hits jQuery:
[{something: "foo", whatever:23}, {something: "bar", whatever, 32}]
If your XSLT created this, I would (hopefully) work fine with getJSON.
change . Now I see your problem.
Your JSON response contains multiple values ββfor "R" inside an outer object. This won't work: if "R" is a list, it must be single , which is an array.
{"GSP": ..., "R":[{"U": ... }, {"U": ... }, {"U": ...}], ...}
a source to share