getJSON returning empty array [] from properly formatted nested JSON object
Hi jQuery forum,
I've been wracking my head on a weird bug for an embarrassingly long amount of time. Google's been of no help so I hope somebody can lend a hand. I have a PHP script that returns a properly formatted JSON object (I've validated it using JSONLint) that looks like the following:
{ "ID":"23",
"LastName":"Moe",
"FirstName":"Ronnie",
"Orders":[{"OrderNumber":"1","ItemNumber":"1"},
{"OrderNumber":"1","ItemNumber":"2"}]}
Pretty simple. But when I use getJSON to grab it and store it in a variable called "data", the JSON is *almost* parsed properly. That is, data.LastName returns "Moe" but data.Orders returns undefined. When I grab the JSON as text using $.ajax(), it reveals an empty Orders list:
{ "ID":"23",
"LastName":"Moe",
"FirstName":"Ronnie",
"Orders":[]}
Why would the Orders information be selectively omitted? It doesn't make sense. What makes even less sense is that when I manually call $.ajax() from the Safari debugger console, it returns the properly formatted JSON object, i.e., the full Orders list. Any ideas why this might be happening?