" {"error":"ApplicationException","reason":"Data types of key columns do not match. 'USERS.lastmodifiedtime' is of 'TIMESTAMP', 'state_list.name' is of 'VARCHAR'."} "
Is stored in string format, I need it in json format
" {"error":"ApplicationException","reason":"Data types of key columns do not match. 'USERS.lastmodifiedtime' is of 'TIMESTAMP', 'state_list.name' is of 'VARCHAR'."} "
Is stored in string format, I need it in json format
Share Improve this question edited Feb 28, 2013 at 7:10 Arun P Johny 388k68 gold badges531 silver badges532 bronze badges asked Feb 28, 2013 at 6:56 Ashwin HegdeAshwin Hegde 8672 gold badges8 silver badges12 bronze badges 2- 2 JSON is a string format, so it's already JSON. – Guffa Commented Feb 28, 2013 at 6:57
- In regards to the various answers here -- if you're trying to decide whether to use JSON.parse or jQuery.parseJSON, you should be aware that the jQuery version is better for cross-browser patibility. See the following post stackoverflow./questions/10362277/… – Aaron Blenkush Commented Feb 28, 2013 at 7:02
5 Answers
Reset to default 4Modern browsers have built in parser JSON.parse(string)
.
If you have to support older browsers you can add json2/json3 libraries. These will add the JSON.parse support if native support is not present in the browser.
If the string is not valid then a parse error will be thrown, in your case it looks like you may have to escape the '
s.
Use
jQuery.parseJSON( json )
example
var obj = jQuery.parseJSON('{"error":"ApplicationException"}');
for more info see details
To convert the JSON-string1 to Object
, parse
it. You should mind escaping apostrophes here:
JSON.parse('{"error":"ApplicationException","reason":"Data types of key columns do not match. \'USERS.lastmodifiedtime\' is of \'TIMESTAMP\', \'state_list.name\' is of \'VARCHAR\'."}')
1 JSON: JavaScript Object Notation
You could use something like this
var obj = jQuery.parseJSON('{"error":"ApplicationException"}');
You can use (jQuery)
$.parseJSON(STRING);