" {"error":"ApplicationException","reason":"Data types of key columns do not match. 'USERS.lastmodifiedtime' is of 'TIMESTAMP', 'state_list.name' is of 'VARCHAR'."} "
转换字符串对象到JSON对象
是存储在字符串格式,我需要它以JSON格式
" {"error":"ApplicationException","reason":"Data types of key columns do not match. 'USERS.lastmodifiedtime' is of 'TIMESTAMP', 'state_list.name' is of 'VARCHAR'."} "
转换字符串对象到JSON对象
是存储在字符串格式,我需要它以JSON格式
使用
jQuery.parseJSON(json)
例如
var obj = jQuery.parseJSON('{"error":"ApplicationException"}');
为
$.parseJSON(STRING);
你可以使用类似这样
var obj = jQuery.parseJSON('{"error":"ApplicationException"}');
现代浏览器内置解析器JSON.parse(string)
更多信息see details
到JSON- 串转换为Object
,parse
它。你应该介意这里转义单引号:
JSON.parse('{"error":"ApplicationException","reason":"Data types of key columns do not match. \'USERS.lastmodifiedtime\' is of \'TIMESTAMP\', \'state_list.name\' is of \'VARCHAR\'."}')
JSON:Ĵ AVA 小号 CRIPT Ø bject ň浮选
JSON是一个字符串格式,所以它的已经是JSON。 – Guffa 2013-02-28 06:57:50
关于这里的各种答案 - 如果您试图决定是使用JSON.parse还是jQuery.parseJSON,您应该知道jQuery版本更适合跨浏览器兼容性。看到下面的帖子http://stackoverflow.com/questions/10362277/jquery-parsejson-vs-json-parse – 2013-02-28 07:02:58