我已经使用正常的内容测试了我的json数据。
充足的数据如下:
{
"language": "XYZ",
"content": {
"GEN": "this is test",
"EXO": "this is test"
}
}
{
"language": "XYZ",
"content": {
"GEN": "\id GEN\n\c 1\n\p\n\v 1 In the beginning God created the heavens and the earth.\n\v 2 And the earth was without form and was void form.",
"EXO": "\id EXO\n\c 1\n\p\n\v 1 Now these are the names of the children of Israel, which came to Egypt; every man and his household came with Jacob\n\v 2 Reuben, Simeon, Levi, and Judah"
}
}
答案 0 :(得分:1)
JSON允许的唯一反斜杠转义序列是\b
,\f
,\n
,\r
,\t
和\"
。反斜杠的所有其他用法必须转义为\\
。问题是\i
(和一些其他转义序列)对JSON没有任何意义,因此是语法错误。改为将其写为\\i
。
答案 1 :(得分:0)
对于转义序列,您可以将对象转换为JSON字符串,然后解析如下
var obj= {
"language": "XYZ",
"content": {
"GEN": "\id GEN\n\c 1\n\p\n\v 1 In the beginning God created the heavens and the earth.\n\v 2 And the earth was without form and was void form.",
"EXO": "\id EXO\n\c 1\n\p\n\v 1 Now these are the names of the children of Israel, which came to Egypt; every man and his household came with Jacob\n\v 2 Reuben, Simeon, Levi, and Judah"
}
};
var json= JSON.stringify(obj);
这对你来说会更简单。