0

" {"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

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
Ashwin Hegde
  • 857
  • 2
  • 8
  • 11
  • 2
    JSON is a string format, so it's already JSON. – Guffa Feb 28 '13 at 06: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 compatibility. See the following post http://stackoverflow.com/questions/10362277/jquery-parsejson-vs-json-parse – Aaron Blenkush Feb 28 '13 at 07:02

5 Answers5

4

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.

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
2

Use

jQuery.parseJSON( json )

example

var obj = jQuery.parseJSON('{"error":"ApplicationException"}');

for more info see details

Satpal
  • 132,252
  • 13
  • 159
  • 168
2

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

KooiInc
  • 119,216
  • 31
  • 141
  • 177
0

You could use something like this

var obj = jQuery.parseJSON('{"error":"ApplicationException"}');
Hass
  • 1,628
  • 1
  • 18
  • 31
0

You can use (jQuery)

$.parseJSON(STRING);
Sudip Pal
  • 2,041
  • 1
  • 13
  • 16