I'd like to read a JSON "tree" from a java byte array and write a JSON "tree" back out as java byte array using Jackson. One way to do it is shown below:
ObjectMapper om = new ObjectMapper(); JsonNode old = om.createObjectNode(); byte arr = om.writeValueAsBytes(old); JsonNode new = om.readTree(arr);
However, Jackson these days recommends the use of ObjectReader and ObjectWriter instead of ObjectMapper, because of thread safety in configuration, but also because of optimizations that might be relevant for them only. But, ObjectReader does not support readTree with byte arrays directly, and writeValueAsBytes is more generic than writeTree so there might be a way (and a reason) to skip the type mapping logic somehow.
So, today, with the most recent Jackson (2.5), what is the fastest/best/recommended way to do these two conversions?