2014-02-19 94 views
0

當我試圖解析此JSON我在http://jsoneditoronline.org/JSON畸形如何糾正

[{"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":""}] 
+4

你不「糾正」壞json。你首先糾正產生JSON的任何東西。 –

+1

我實際上在http://jsonlint.com/上測試了這一點,並且存在許多問題,文本在多行中被打破。你不能在json中找到它,並且需要糾正,就像Marc B所說的那樣。 –

回答

1

你有一個字符串常量一個新的生產線得到一個錯誤期待數:

"seriesname": "Census of State and Federal Correctional 

Facilities", 

應該是:

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

還有幾個相同的確切錯誤。

真的,無論創建此JSON需要正確轉換數據,包括將任何回車或換行轉換爲適當的轉義序列。

+0

謝謝你們,你們是正確的空間殺死輸出。任何人都可以推薦一個工具,可以清理格式不正確的JSON數據?從Excel電子表格中獲得這些數據。 –