Archive For 16. January 2016

Deserializing a piece of json into a string

By |

Deserializing a piece of json into a string

Jackson provides a functionallity with com.fasterxml.jackson.annotation.JsonRawValue ¬†annotation to serialize a raw string to the output json. The opposite way is currently not supported directly, but a simple custom Deserializer can add the required functionallity: public class JsonRawValueDeserializer extends JsonDeserializer<String> { @Override public String deserialize(JsonParser jp, DeserializationContext context) throws IOException { return jp.readValueAsTree().toString(); } } The…

Read more »