" {"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
Modern 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"}');