title: Jackson JsonNode to string with sorted keys
body: <p>I'm using <a href="https://github.com/FasterXML/jackson">Jackson 2.2.3</a> 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 - <code>JsonNode jn = ObjectMapper.readTree(String s)</code>.</p>
  
  <p>It appears the correct method is <a href="http://fasterxml.github.io/jackson-databind/javadoc/2.2.0/com/fasterxml/jackson/databind/ObjectMapper.html#writeTree%28com.fasterxml.jackson.core.JsonGenerator,%20com.fasterxml.jackson.databind.JsonNode%29"><code>void writeTree(JsonGenerator jgen,JsonNode rootNode)</code></a>. However, I see no way to then get the serialized <code>String</code> from the <a href="http://fasterxml.github.io/jackson-core/javadoc/2.2.0/com/fasterxml/jackson/core/JsonGenerator.html?is-external=true"><code>JsonGenerator</code></a>. I presume that <a href="http://fasterxml.github.io/jackson-databind/javadoc/2.2.0/com/fasterxml/jackson/databind/SerializationFeature.html#ORDER_MAP_ENTRIES_BY_KEYS"><code>SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS</code></a> will still apply, since the <code>JsonGenerator.Feature</code>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 <code>JsonGenerator</code>?</p>