I'm trying to parse JSON with jQuery I get from a remote server through AJAX. The JSON data is like: {identifier:"ID", label:"LABEL"}
but unable to. Apparently, the field identifier and label has no double quotes. It works when tested on my local test site with double quotes.
Can it be made to work without quotes with jQuery? I have searched around and have found no solutions.
Any input is appreciated. Thanks.
Yeah, it's not valid JSON, blahblahblah... like everyone cares if it's valid or not.
At least I don't care, I just want to parse it, so I wrote jsonlite.
with Jsonlite, you can do this:
var s = '{name: jsonlite, birthday: {year: 2013, month: 7, day: 7}, isGreat: true}';
var obj = jsonlite.parse(s);
Which produces exactly the same result as the code below:
var s = '{"name": "jsonlite", "birthday": {"year": 2013, "month": 7, "day": 7}, "isGreat": true}';
var obj = $.parseJSON(s);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With