jQuery .getJSON() Not Parsing All Objects jQuery .getJSON() Not Parsing All Objects json json

jQuery .getJSON() Not Parsing All Objects


You might try doing "getJSON" yourself with your own "jsonpCallback" function. If the response from the API you're calling looks like a comma-separated list of JSON expressions, then the jQuery automatically-constructed callback function will only see the first one.

In other words, if the API returns

{something: "foo", whatever:23}, {something: "bar", whatever, 32}

then what'll end up in the response script block is:

magicJqueryCallback({something: "foo", whatever:23}, {something: "bar", whatever, 32})

The jQuery callback is declared as having just 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 could have it wrap the list of responses in a set of square brackets, before it even gets to jQuery:

[{something: "foo", whatever:23}, {something: "bar", whatever, 32}]

If your XSLT produced that, it would (I hope) work just fine with getJSON.

edit OK, I see your problem now.

Your JSON response contains multiple values for "R" inside the outer object. That's not going to work: if "R" is a list, it needs to have a single value, with that value being an array.

  {"GSP": ..., "R":[{"U": ... }, {"U": ... }, {"U": ...}], ...}


Alternatively you could always just use the $.ajax function and then simply eval the resulting JSON. I realize this is normally ill-advised but since you can be certain the Google Search Appliance won't inject an attack of any kind it could be used in this case.