I’m making an ajax call and receiving back what it supposedly json resopnse. I first need to know if this json is even well-formed, and if it is then how do I parse it with jquery? Here’s what it looks like. They’re only 2 records.
When I alert(response); I get
[object Object],[object Object]
and when I console.debug(response); I get the following 2 objects in this format
[Object { RowId=1, more...}, Object { RowId=2, more...}]
and when I click the more link for any of them, I get this
RowId 1
Description "This is description of Row1"
Total 15
So does this look like well-formed json. Secondly, how do I parse it and use it in my jquery. I need a parsing way that’s well supported. I tried alert(JSON.parse(resp)) but it did absolutely nothing.
That’s valid JSON, as it’s not JSON at all any more. The jQuery Ajax call has already parsed the JSON into Javascript objets for you. The reason that you can’t parse it is that it’s parsed already.
If you want to parse the JSON yourself, you have to use the data type
textso that you get the result unparsed.