Convenience method for doing two-step conversion from a given value, into an instance of a given type, T].
Convenience method for doing two-step conversion from a given value, into an instance of a given type, T]. This is functionality equivalent to first serializing the given value into JSON, then binding JSON data into a value of the given type, but may be executed without fully serializing into JSON. The same converters (serializers, deserializers) will be used for data binding, meaning the same object mapper configuration works.
Note: when Finatra's com.twitter.finatra.jackson.caseclass.exceptions.CaseClassMappingException
is thrown inside of the the ObjectMapper#convertValue
method, Jackson wraps the exception
inside of an IllegalArgumentException. As such we unwrap to restore the original
exception here. The wrapping occurs because the com.twitter.finatra.jackson.caseclass.exceptions.CaseClassMappingException
is a sub-type of java.io.IOException (through extension of com.fasterxml.jackson.databind.JsonMappingException
--> com.fasterxml.jackson.core.JsonProcessingException --> java.io.IOException.
the type to which to be converted.
the value to be converted.
a new instance of type T converted from the given Any type.
Convenience method for doing two-step conversion from given value, into an instance of given value type, JavaType if (but only if!) conversion is needed.
Convenience method for doing two-step conversion from given value, into an instance of given value type, JavaType if (but only if!) conversion is needed. If given value is already of requested type, the value is returned as is.
This method is functionally similar to first serializing a given value into JSON, and then binding JSON data into a value of the given type, but should be more efficient since full serialization does not (need to) occur. However, the same converters (serializers, deserializers) will be used for data binding, meaning the same object mapper configuration works.
Note: it is possible that in some cases behavior does differ from full serialize-then-deserialize cycle. It is not guaranteed, however, that the behavior is 100% the same -- the goal is just to allow efficient value conversions for structurally compatible Objects, according to standard Jackson configuration.
Further note that this functionality is not designed to support "advanced" use cases, such as conversion of polymorphic values, or cases where Object Identity is used.
value from which to convert.
type to be converted into.
a new instance of type JavaType converted from the given Any type.
Read a value from a JsonParser into a type T.
Read a value from a JsonParser into a type T.
Read a value from a String into a type T.
Read a value from a String into a type T.
Read a value from an Array[Byte] into a type T.
Read a value from an Array[Byte] into a type T.
Read a value from an InputStream (caller is responsible for closing the stream) into a type T.
Read a value from an InputStream (caller is responsible for closing the stream) into a type T.
Convert from a JsonNode into a type T.
Convert from a JsonNode into a type T.
Read a value from a ByteBuffer into a type T.
Read a value from a ByteBuffer into a type T.
Read a value from a Buf into a type T.
Read a value from a Buf into a type T.
Constructed ObjectWriter that will serialize objects using specified pretty printer for indentation (or if null, no pretty printer).
Constructed ObjectWriter that will serialize objects using specified pretty printer for indentation (or if null, no pretty printer).
Returns the currently configured PropertyNamingStrategy
Returns the currently configured PropertyNamingStrategy
Factory method for constructing a com.fasterxml.jackson.databind.ObjectReader that will read or update instances of specified type, T.
Factory method for constructing a com.fasterxml.jackson.databind.ObjectReader that will read or update instances of specified type, T.
the type for which to create a com.fasterxml.jackson.databind.ObjectReader
the created com.fasterxml.jackson.databind.ObjectReader.
Method for registering a module that can extend functionality provided by this mapper; for example, by adding providers for custom serializers and deserializers.
Method for registering a module that can extend functionality provided by this mapper; for example, by adding providers for custom serializers and deserializers.
Module to register.
this mutates the underlying ObjectMapper of this mapper.
Method that can be used to serialize any value as a pretty printed String.
Method that can be used to serialize any value as a pretty printed String. Uses the prettyObjectMapper and calls Any) on the given value.
the value to serialize.
the pretty printed String representing the serialized value.
Any)
Convenience method for doing the multi-step process of serializing a Map[String, String]
to a Buf.
Convenience method for doing the multi-step process of serializing a Map[String, String]
to a Buf.
the Map[String, String]
to convert.
the Buf.ByteArray.Owned representing the serialized value.
Method that can be used to serialize any value as JSON output, using the output stream provided (using an encoding of com.fasterxml.jackson.core.JsonEncoding#UTF8.
Method that can be used to serialize any value as JSON output, using the output stream provided (using an encoding of com.fasterxml.jackson.core.JsonEncoding#UTF8.
Note: this method does not close the underlying stream explicitly here; however, the com.fasterxml.jackson.core.JsonFactory this mapper uses may choose to close the stream depending on its settings (by default, it will try to close it when com.fasterxml.jackson.core.JsonGenerator constructed is closed).
the value to serialize.
the OutputStream to which to serialize.
Method that can be used to serialize any value as a Buf.
Method that can be used to serialize any value as a Buf. Functionally equivalent to calling Any) and then wrapping the results in an "owned" Buf.ByteArray.
the value to serialize.
the Buf.ByteArray.Owned representing the serialized value.
Buf.ByteArray.Owned
Any)
Method that can be used to serialize any value as a Array[Byte]
.
Method that can be used to serialize any value as a Array[Byte]
. Functionally equivalent
to calling JacksonObjectMapper#writeValue(Writer,Object) with a java.io.ByteArrayOutputStream and
getting bytes, but more efficient. Encoding used will be UTF-8.
the value to serialize.
the Array[Byte]
representing the serialized value.
Method that can be used to serialize any value as a String.
Method that can be used to serialize any value as a String. Functionally equivalent to calling JacksonObjectMapper#writeValue(Writer,Object) with a java.io.StringWriter and constructing String, but more efficient.
the value to serialize.
the String representing the serialized value.
(Since version 2019-10-10) Use com.twitter.finatra.jackson.ScalaObjectMapper