1
votes

I used Gson to convert java list to JSON and returned as a response to the AJAX call.
I'm getting the following data as the json object to success method variable data.

[{Id:121,RefId:123,Date:Sep 22, 2012 12:00:00 AM}]

while parsing it is giving the following error message,

JSON.parse: expected property name or '}' In Firebug.

I used this code to return json object.

Gson gson = new Gson();
String json = gson.toJson(list);

where is the problem of Jquery not able to handle this ?
Any reply is highly appreciatable..

1
Your JSON needs double-quotes. - Ram
The date/time without quotes is a problem. Can you provide details about how you generated your JSON? - erturne
@erturne I added my code to send json object.. check once.. - Mr.Chowdary

1 Answers

5
votes

That seems to be invalid JSON, it's missing all the quotes around the strings.

It should be something like this:

[{"Id": 121, "RefId": 123, "Date": "Sep 22, 2012 12:00:00 AM"}]