class ScalaObjectMapper extends AnyRef
A thin wrapper over a jackson-module-scala com.fasterxml.jackson.module.scala.ScalaObjectMapper
- Alphabetic
- By Inheritance
- ScalaObjectMapper
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new ScalaObjectMapper(underlying: JacksonScalaObjectMapperType)
- underlying
a configured JacksonScalaObjectMapperType
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def convert[T](any: Any)(implicit arg0: Manifest[T]): T
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 a com.twitter.util.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.util.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.- T
the type to which to be converted.
- any
the value to be converted.
- returns
a new instance of type
T
converted from the given Any type.
- def convert(from: Any, toValueType: JavaType): AnyRef
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.
- from
value from which to convert.
- toValueType
type to be converted into.
- returns
a new instance of type JavaType converted from the given Any type.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def parse[T](jsonParser: JsonParser)(implicit arg0: Manifest[T]): T
Read a value from a JsonParser into a type
T
. - def parse[T](string: String)(implicit arg0: Manifest[T]): T
Read a value from a String into a type
T
. - def parse[T](bytes: Array[Byte])(implicit arg0: Manifest[T]): T
Read a value from an Array[Byte] into a type
T
. - def parse[T](inputStream: InputStream)(implicit arg0: Manifest[T]): T
Read a value from an InputStream (caller is responsible for closing the stream) into a type
T
. - def parse[T](jsonNode: JsonNode)(implicit arg0: Manifest[T]): T
Convert from a JsonNode into a type
T
. - def parse[T](byteBuffer: ByteBuffer)(implicit arg0: Manifest[T]): T
Read a value from a ByteBuffer into a type
T
. - def parse[T](buf: Buf)(implicit arg0: Manifest[T]): T
Read a value from a Buf into a type
T
. - lazy val prettyObjectMapper: ObjectWriter
Constructed ObjectWriter that will serialize objects using specified pretty printer for indentation (or if null, no pretty printer).
- def propertyNamingStrategy: PropertyNamingStrategy
Returns the currently configured PropertyNamingStrategy
- def reader[T](implicit arg0: Manifest[T]): ObjectReader
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
.- T
the type for which to create a com.fasterxml.jackson.databind.ObjectReader
- returns
the created com.fasterxml.jackson.databind.ObjectReader.
- def registerModule(module: Module): ObjectMapper
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
com.fasterxml.jackson.databind.Module to register.
- Note
this mutates the underlying com.fasterxml.jackson.databind.ObjectMapper of this ScalaObjectMapper.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- val underlying: JacksonScalaObjectMapperType
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def writePrettyString(any: Any): String
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.
- any
the value to serialize.
- returns
the pretty printed String representing the serialized value.
- See also
Any)
- def writeStringMapAsBuf(stringMap: Map[String, String]): Buf
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.- stringMap
the
Map[String, String]
to convert.- returns
the Buf.ByteArray.Owned representing the serialized value.
- def writeValue(any: Any, outputStream: OutputStream): Unit
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).
- any
the value to serialize.
- outputStream
the OutputStream to which to serialize.
- def writeValueAsBuf(any: Any): Buf
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.
- any
the value to serialize.
- returns
the Buf.ByteArray.Owned representing the serialized value.
- See also
Any)
Buf.ByteArray.Owned
- def writeValueAsBytes(any: Any): Array[Byte]
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.- any
the value to serialize.
- returns
the
Array[Byte]
representing the serialized value.
- def writeValueAsString(any: Any): String
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.
- any
the value to serialize.
- returns
the String representing the serialized value.