I have a HashMap
object which I want to convert to JsonNode
tree using com.fasterxml.jackson.databind.ObjectMapper
. What is the best w
First transform your map in a JsonNode :
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNodeMap = mapper.convertValue(myMap, JsonNode.class);
Then add this node to your ObjectNode with the set method :
myObjectNode.set("myMapName", jsonNodeMap);
To convert from JsonNode to ObjectNode use :
ObjectNode myObjectNode = (ObjectNode) myJsonNode;