可以直接将Java对象转换为JsonNode对象吗?
我发现解决这个问题的唯一方法是将Java对象转换为String,然后再转换为JsonNode:
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(object);
JsonNode jsonNode = mapper.readTree(json);发布于 2012-08-06 21:06:39
从Jackson 1.6开始,您可以使用:
JsonNode node = mapper.valueToTree(map);或
JsonNode node = mapper.convertValue(object, JsonNode.class);来源:is there a way to serialize pojo's directly to treemodel?
https://stackoverflow.com/questions/11828368
复制相似问题