2014-06-18 36 views
4

任何人都知道为什么这个JSON无效?为什么JSON在字符串中逗号无效?

{"street_address":"Stone House Lane, Peckforton
, Tarporley
, London, Cheshire"} 

我使用杰克逊Java和它的抱怨

java.lang.IllegalArgumentException: com.fasterxml.jackson.core.JsonParseException:  Unexpected end-of-input: was expecting closing quote for a string value 
at [Source: [email protected]; line: 1, column: 405] 

我注意到这个JSON被认为是无效的这个在线网站,以及: http://jsonviewer.stack.hu/

答:谢谢,对于那些很好奇的人,我已经使用tr -cd'\ 11 \ 12 \ 15 \ 40- \ 176'<删除了这些无法读取的字符> cleanFile

+1

您能否提供导致问题的完整代码片段? –

回答

8

复制/粘贴确切文本后,它显示为无效的JSON变量。然后,我只是将相同的内容复制/粘贴到记事本中(使用Windows 7),并注意到字符串中有奇怪的字符(这些字符不能在本页面或Web编辑器中看到,所以我使用了空格):

{"street_address":"Stone House Lane, Peckforton
 , Tarporley
 , London, Cheshire"} 
              ^  ^
               here and here 

我刚刚删除它们,并按预期工作。从这里复制/粘贴:

{"street_address":"Stone House Lane, Peckforton, Tarporley, London, Cheshire"} 

一个更深入的评估后,该字符的十六进制表示是\ u80A8。

+0

谢谢,对于那些很好奇的人,我已经使用tr -cd'\ 11 \ 12 \ 15 \ 40- \ 176'删除了这些无法读取的字符。cleanFile – Popcorn

相关问题