0

我正在使用 AJAX 将 JSON 对象从 servlet 发送到 JSP。我的 JSON 对象内部包含一个字符串值。并且该字符串在其中包含双引号。我的 JSON 不解析它。我收到以下错误:

 {"diagnosis":[{"NAME":"new_diagnosis_1 \[1020\]:2000000006001"},{"NAME":"new_diagnosis_2 \[1021\]:2000000006003"},{"NAME":"new_"dise"sed \[1023\]:2000000009001"},{"NAME":"new_d"ise"sef \[1024\]:2000000009003"}]}

注意new_"dise"sednew_d"ise"sef

我需要一个解决方案。

4

1 回答 1

2

你的 json 无效

尝试这个

{
    "diagnosis": [
        {
            "NAME": "new_diagnosis_1 [1020]:2000000006001" 
        },
        {
            "NAME": "new_diagnosis_2 [1021]:2000000006003" 
        },
        {
            "NAME": "new_\"dise\"sed [1023]:2000000009001" 
        },
        {
            "NAME": "new_d\"ise\"sef [1024]:2000000009003" 
        } 
    ]
}

用于\转义引号

你可以在json 这里 验证你的http://www.jsonlint.com/

于 2011-03-31T12:06:54.320 回答