I'm using Jackson 2.2.3 and need to convert a JsonNode tree into a string with sorted field keys. It's completely unclear to me how to do this, especially since the opposite is so simple - JsonNode jn = ObjectMapper.readTree(String s)
.
It appears the correct method is void writeTree(JsonGenerator jgen,JsonNode rootNode)
. However, I see no way to then get the serialized String
from the JsonGenerator
. I presume that SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS
will still apply, since the JsonGenerator.Feature
s don't have that option. Is there a simpler way to do this - or if not, how do I retrieve the serialized string from the JsonGenerator
?