2017-05-14 194 views
0

我想一個JSON發送到一個REST控制器,寫在春季,無論什麼我都試過 - 傑克遜拋出一個異常:無法解析JSON

org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Illegal character ((CTRL-CHAR, code 10)): 

這是JSON:

{"fact checking": [ {"fact": "Clinton Foundation has no ships, didn’t smuggle refugees", "status":"false","source":"http://www.politifact.com/punditfact/statements/2017/may/12/blog-posting/fake-news-clinton-foundation-has-no-ships-didnt-sm/", "actual":"One way to tell if the story is made up, beyond its absurdity, is a link allegedly to a CNN story that is actually to a Forrest Gump meme that reads, "Are you stupid or something?""}, {"fact":"AG Jeff Sessions claims district attorneys charge immigrants for lesser crimes", "source":"http://www.politifact.com/truth-o-meter/statements/2017/may/10/jeff-sessions/sessions-claims-district-attorneys-charge-immigran/", "status":"half true", "actual":"Sessions spoke about "criminal aliens," a term generally applied to non-U.S. citizens – living in the United States legally or illegally – who are convicted of crimes."}, {"fact":"Is Sean Spicer Wearing Mismatched Shoes?", "source":"http://www.snopes.com/sean-spicer-shoes/", "status":"true", "actual":"A photograph showing the White House press secretary wearing two different types of footwear is real, but the oddity appears to serve a medical purpose rather than an avant-garde fashion choice."} ]} 

有什麼建議嗎?

+0

你見過這樣的文件? http://stackoverflow.com/questions/31537153/jsonparseexception-illegal-unquoted-character-ctrl-char-code-10 – RubioRic

回答

1

我貼你的JSON文檔中的JSON formatter,正如你可以看到它抱怨在404 那是因爲你沒有正確的位置躲過了文件和雙引號(「)的位置意外的標記404混淆瞭解析器 您應該通過用\「(或\'爲單引號)替換出現在鍵/值內的引號。

逃避串後,formatter解析成功

1

您的JSON在一個字符串值中有2個雙引號。看截圖。 enter image description here

我相信從源返回的JSON不正確或者您提供的字符編碼不正確。