com.fasterxml.jackson.core.JsonParseException:读取json文件时出现意外字符(代码160)

时间:2016-08-19 20:31:10

标签: java json java-ee

我正在从文件中读取以下json内容并转换为地图但我得到以下异常。如果有人遇到过这样的问题,请告诉我。我验证了我的json内容并且看起来有效。不知道为什么会出现这个错误。

Json内容:

host_key_checking=False

代码:

fruits<-c("apple","bananas","pineapple","kiwi","strawberry")
A<-c("9.8","12","3.5","6.4","2.5")
B<-c("21","11","13","36.5","47.2")
C<-c("62.2","58.3","41.2","38.1","35.5")

df<-data.frame(fruits, A, B, C)
df
      fruits   A    B    C
1      apple 9.8   21 62.2
2    bananas  12   11 58.3
3  pineapple 3.5   13 41.2
4       kiwi 6.4 36.5 38.1
5 strawberry 2.5 47.2 35.5

library(reshape2)
melt(df, id="fruits")

       fruits variable value
1       apple        A   9.8
2     bananas        A    12
3   pineapple        A   3.5
4        kiwi        A   6.4
5  strawberry        A   2.5
6       apple        B    21
7     bananas        B    11
8   pineapple        B    13
9        kiwi        B  36.5
10 strawberry        B  47.2
11      apple        C  62.2
12    bananas        C  58.3
13  pineapple        C  41.2
14       kiwi        C  38.1
15 strawberry        C  35.5

异常详细信息:

{
    "Results":[{         
        "TotalPositiveFeedbackCount": 0      
    },{
        "TotalPositiveFeedbackCount": 1      
    }   ]
}

1 个答案:

答案 0 :(得分:0)

您的JSON内容包含不间断空格(字符代码160,通常称为&nbsp;),很可能是由于复制和粘贴使用&nbsp;来使JSON缩进的JSON(通常是从网页)。 / p>

enter image description here

您可以使用

对其进行修复
responseJson = responseJson.replace('\u00A0',' ');