JSON不正确的纠正方法

时间:2014-02-19 18:51:45

标签: json

当我尝试解析这个json时,我得到一个错误,期待http://jsoneditoronline.org/

的数字
[{"urltitle":"","urltypeid":"2,4,4,5,5","seriesname":"Census of State and Federal    Correctional 

Facilities","titleb":"Census of State and Federal Correctional Facilities, 1995","url":"\/content\/pub\/press

\/CSFCF95.PR,\/content\/pub\/pdf\/CSFC95EX.PDF,\/content\/pub\/pdf\/Csfcf95.pdf,\/content\/pub\/ascii

\/csfc95ex.txt,\/content\/pub\/ascii\/csfcf95.txt","releasedate":"1997-08-07 00:00:00.0","urltype":"Press Release 

","pubproductid":535,"title":"CENSUS OF STATE AND FEDERAL CORRECTIONAL FACILITIES, 1995","tagkeywords":""},

{"urltitle":"","urltypeid":"2,4,4,5,13","seriesname":"Indicators of School Crime and Safety","titleb":"Indicators 

of School Crime and Safety, 2000","url":"\/content\/pub\/press\/iscs00.pr,\/content\/pub\/pdf\/iscs00.pdf,

\/content\/pub\/pdf\/iscs00ex.pdf,\/content\/pub\/ascii\/iscs00.txt,\/content\/pub\/sheets

\/iscs00.zip","releasedate":"2000-10-26 00:00:00.0","urltype":"Press Release 

","pubproductid":992,"title":"INDICATORS OF SCHOOL CRIME AND SAFETY, 2000","tagkeywords":""}] 

1 个答案:

答案 0 :(得分:1)

你在字符串常量中有一个新行:

 "seriesname": "Census of State and Federal    Correctional 

Facilities",

应该是:

 "seriesname": "Census of State and Federal    Correctional\n\nFacilities",

还有几个相同的确切错误。

真的,无论创建这个JSON,都需要正确转义数据,包括将任何回车符或换行符转换为适当的转义序列。