Class JacksonUtils
java.lang.Object
org.apache.druid.java.util.common.jackson.JacksonUtils
-
Field Summary
FieldsModifier and TypeFieldDescription -
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.databind.JsonSerializer<Object>getSerializer(com.fasterxml.jackson.databind.SerializerProvider serializerProvider, Class<?> clazz) Returns a serializer for a particular class.static ObjectreadObjectUsingDeserializationContext(com.fasterxml.jackson.core.JsonParser jp, com.fasterxml.jackson.databind.DeserializationContext deserializationContext, com.fasterxml.jackson.databind.JavaType javaType) static <T> TreadObjectUsingDeserializationContext(com.fasterxml.jackson.core.JsonParser jp, com.fasterxml.jackson.databind.DeserializationContext deserializationContext, Class<T> clazz) Reads an object using theJsonParser.static <T> TreadValue(com.fasterxml.jackson.databind.ObjectMapper mapper, byte[] bytes, com.fasterxml.jackson.core.type.TypeReference<T> valueType) Silences Jackson'sIOException.static <T> TreadValue(com.fasterxml.jackson.databind.ObjectMapper mapper, byte[] bytes, com.fasterxml.jackson.databind.JavaType valueType) Silences Jackson'sIOException.static <T> TSilences Jackson'sIOException.static byte[]Convert the given object to an array of bytes.static voidwriteObjectUsingSerializerProvider(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, com.fasterxml.jackson.databind.SerializerProvider serializers, Object o) Serializes an object using aJsonGenerator.static StringwriteValueAsString(com.fasterxml.jackson.databind.ObjectMapper jsonMapper, Object value)
-
Field Details
-
TYPE_REFERENCE_MAP_STRING_OBJECT
-
TYPE_REFERENCE_MAP_STRING_STRING
-
TYPE_REFERENCE_MAP_STRING_BOOLEAN
-
-
Method Details
-
readValue
public static <T> T readValue(com.fasterxml.jackson.databind.ObjectMapper mapper, byte[] bytes, Class<T> valueType) Silences Jackson'sIOException. -
readValue
public static <T> T readValue(com.fasterxml.jackson.databind.ObjectMapper mapper, byte[] bytes, com.fasterxml.jackson.databind.JavaType valueType) Silences Jackson'sIOException. -
readValue
public static <T> T readValue(com.fasterxml.jackson.databind.ObjectMapper mapper, byte[] bytes, com.fasterxml.jackson.core.type.TypeReference<T> valueType) Silences Jackson'sIOException. -
getSerializer
public static com.fasterxml.jackson.databind.JsonSerializer<Object> getSerializer(com.fasterxml.jackson.databind.SerializerProvider serializerProvider, Class<?> clazz) throws com.fasterxml.jackson.databind.JsonMappingException Returns a serializer for a particular class. If you have aSerializerProvider, this is better than callingJsonGenerator.writeObject(Object)orObjectMapper.writeValue(JsonGenerator, Object), because it avoids re-creating theSerializerProviderfor each serialized object.- Throws:
com.fasterxml.jackson.databind.JsonMappingException
-
writeObjectUsingSerializerProvider
public static void writeObjectUsingSerializerProvider(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, com.fasterxml.jackson.databind.SerializerProvider serializers, @Nullable Object o) throws IOException Serializes an object using aJsonGenerator. If you have aSerializerProvider, this is better than callingJsonGenerator.writeObject(Object), because it avoids re-creating theSerializerProviderfor each serialized object.- Throws:
IOException
-
writeValueAsString
public static String writeValueAsString(com.fasterxml.jackson.databind.ObjectMapper jsonMapper, Object value) throws DruidException - Throws:
DruidException
-
readObjectUsingDeserializationContext
@Nullable public static <T> T readObjectUsingDeserializationContext(com.fasterxml.jackson.core.JsonParser jp, com.fasterxml.jackson.databind.DeserializationContext deserializationContext, Class<T> clazz) throws IOException Reads an object using theJsonParser. It reuses the providedDeserializationContextwhich offers better performance that callingJsonParser.readValueAs(Class)because it avoids re-creating theDeserializationContextfor each readValue call- Throws:
IOException
-
readObjectUsingDeserializationContext
@Nullable public static Object readObjectUsingDeserializationContext(com.fasterxml.jackson.core.JsonParser jp, com.fasterxml.jackson.databind.DeserializationContext deserializationContext, com.fasterxml.jackson.databind.JavaType javaType) throws IOException -
toBytes
Convert the given object to an array of bytes. Use when the object is known serializable so that the Jackson exception can be suppressed.
-