json解错误解决com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 13

代码部分:
"imageUrls": {
    "imageUrl1":"https://blog.csdn.net/qq_24504453/article/details/72510241x1.png",
    "imageUrl2":"https://blog.csdn.net/qq_24504453/article/details/72510241x2.png"
    "imageUrl3":"https://blog.csdn.net/qq_24504453/article/details/72510241x3.png"
},

解析时报错:

Map ret = JsonUtils.fromJson(json,  new TypeToken>(){});

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 92

at com.google.gson.Gson.fromJson(Gson.java:818)

at com.google.gson.Gson.fromJson(Gson.java:768)

at com.google.gson.Gson.fromJson(Gson.java:717)

at com.hupun.chanjet.util.JsonUtils.fromJson(JsonUtils.java:298)

at com.hupun.chanjet.util.JsonUtils.fromJson(JsonUtils.java:318)

at 

解决办法:
URLEncoder.encode("https://blog.csdn.net/qq_24504453/article/details/72510241x3.png","utf8");

变为:
"imageUrls": {
    "imageUrl1":"https%3A%2F%2Fblog.csdn.net%2Fqq_24504453%2Farticle%2Fdetails%2F72510241x1.png",
    "imageUrl2":"https%3A%2F%2Fblog.csdn.net%2Fqq_24504453%2Farticle%2Fdetails%2F72510241x2.png",
    "imageUrl3":"https%3A%2F%2Fblog.csdn.net%2Fqq_24504453%2Farticle%2Fdetails%2F72510241x3.png"
},

正确解决问题

 

 

你可能感兴趣的:(技巧,Java)