Class JSONSerializerUtil


  • public final class JSONSerializerUtil
    extends Object
    Utilities for custom JSON serializers.
    • Method Detail

      • serializeRaw

        public static void serializeRaw​(Object value,
                                        com.fasterxml.jackson.core.JsonGenerator jgen,
                                        com.fasterxml.jackson.databind.SerializerProvider provider)
                                 throws IOException,
                                        com.fasterxml.jackson.core.JsonProcessingException
        Serialize the value without any type information. At times it is convenient to convert an object's internal state into, say, a map of lists and then have Jackson serialize the intermediate object. In those cases we need to suppress type information; otherwise the sub-lists will have type tags.
        Parameters:
        value - the value to serialize
        jgen - the json generator ( this is passed to any custom Jackson serializer )
        provider - the provider ( this is passed to any custom Jackson serializer )
        Throws:
        IOException - if the underlying serializer threw an IOException
        com.fasterxml.jackson.core.JsonProcessingException - if the underlying serializer threw a JsonProcessingException
      • deserializeRaw

        public static <T> T deserializeRaw​(com.fasterxml.jackson.core.JsonParser jp,
                                           com.fasterxml.jackson.databind.DeserializationContext ctxt,
                                           Class<T> clazz)
                                    throws IOException,
                                           com.fasterxml.jackson.core.JsonProcessingException
        Deserialize the value, treating all elements as data rather than as type information. At times it is convenient to convert an object's internal state into, say, a map of lists and then have Jackson serialize the intermediate object. In those cases we need to suppress type information; otherwise the sub-lists will have type tags.
        Type Parameters:
        T - the type to deserialize as
        Parameters:
        jp - the json parser ( this is passed to any custom Jackson deserializer )
        ctxt - the deserialization context ( this is passed to any custom Jackson deserializer )
        clazz - the class to deserialize as
        Returns:
        the parsed object
        Throws:
        IOException - if the underlying deserializer threw an IOException
        com.fasterxml.jackson.core.JsonProcessingException - if the underlying deserializer threw a JsonProcessingException