我使用jackson提供的对象Map器来解析我的json消息。
下面的代码适用于jsonmsg1,但不适用于jsonmsg2,因为它包含双引号。
ObjectMapper objMapper = new ObjectMapper();
JsonNode rootNode = objMapper.rootTree(jsonMessage);
jsonMsg1 ->
{
"key1": "Value1",
"key2":{
"key2_1": "Value2_1"
"key2_2": "Value2_2"
}
}";
jsonMsg2 ->
{
"key1": "Value1",
"key2":"{
"key2_1": "Value2_1",
"key2_2": "Value2_2",
}"
}
当我尝试解析jsonmsg2-->
com.fasterxml.jackson.core.JsonParserException: Unexpected cjaracter ('k' (code 109)): was expecting comma to separate OBJECT entries
暂无答案!
目前还没有任何答案,快来回答吧!