我有一个在java中验证字符串json的方法。
我尝试了最好的库,如 JsonSimple、gson 和 jackson。所有这些都有相同的结果,即 json 字符串有效,下面的代码是我的杰克逊验证方法。
//jackson lib
public static boolean isValidJSON(final String json) throws IOException {
boolean valid = true;
try{
objectMapper.readTree(json);
} catch(JsonProcessingException e){
valid = false;
}
return valid;
}
我希望验证 json 的在线网站对我的代码有相同的结果。
我在这些网站中检查了我的字符串
jsonformatter.curiousconcept.com
jsonlint.com
jsonformatter.org
注意:我的字符串 json 实际上是无效的,但我不知道为什么代码和站点结果不一样?
我的 json 字符串:
{
"hasError": false,
"referenceNumber": "57050377",
"errorCode": 0,
"count": 0,
"ott": "5cd3db66e810db0b",
"result": {
"id": 3551,
"guilds": [{
"id": 56,
"code": "TRANSPORTATION_GUILD"
}],
"subscriptionCount": 0,
"subscribed": false,
"numOfComments": 0,
"rate": {
"rate": 0,
"rateCount": 0
},
"fullAddress": "USA",
"tags": [],
"tagTrees": [],
"active": false,
"apiToken": "b9ea8244e34bb9f8d383467ad82",
"numOfLike": 0,
"numOfDislike": 0
}
}
"id": 3551,
"ssoId": "5884675",
"apiToken": "b9ea80c804e34bb9f8d383467ad82",
{
"count": 0,
"ott": "2558074f8d18f49e",
"result": {
"email": "pos_psp@ptest.land",
"fullAddress": "CHINA",
"tags": [],
"tagTrees": [],
"active": false,
"apiToken": "0a4a31d1fe5c457785145fe7f97bc26e",
"numOfLike": 0,
"numOfDislike": 0,
"username": "pos_psp"
}
}
"id": 3552,
"userId": 1357729
"username": "pos_psp"
有只小跳蛙
暮色呼如
相关分类