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
  • 376,738
  • 64
  • 519
  • 520
Ashwin Hegde
  • 837
  • 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
  • 376,738
  • 64
  • 519
  • 520
2

Use

jQuery.parseJSON( json )

example

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

for more info see details

Satpal
  • 129,808
  • 12
  • 152
  • 166
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
  • 112,400
  • 31
  • 139
  • 174
0

You could use something like this

var obj = jQuery.parseJSON('{"error":"ApplicationException"}');
Hass
  • 1,610
  • 1
  • 17
  • 30
0

You can use (jQuery)

$.parseJSON(STRING);
Sudip Pal
  • 1,981
  • 1
  • 12
  • 16