How to generate an empty json node using jackson-java. I tried with NullNode.instance, but that returns
"totals":null
Whereas I want totals to be an empty instance.
{
"totals": {},
"orderId": "550047004",
"numberOfItems": 2
}
You should use ObjectNode
. It can be created with ObjectMapper
:
ObjectNode node = mapper.createObjectNode();