Package com.couchbase.client.core.json
Class Mapper
- java.lang.Object
-
- com.couchbase.client.core.json.Mapper
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TconvertValue(Object fromValue, com.couchbase.client.core.deps.com.fasterxml.jackson.core.type.TypeReference<T> toValueTypeRef)Converts an object to the requested type usingObjectMapper.convertValue(Object, TypeReference).static <T> TconvertValue(Object fromValue, Class<T> toValueType)Converts an object to the requested type usingObjectMapper.convertValue(Object, Class).static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.node.ArrayNodecreateArrayNode()Returns a new empty ArrayNode.static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.node.ObjectNodecreateObjectNode()Returns a new empty ObjectNode.static <T> TdecodeInto(byte[] input, com.couchbase.client.core.deps.com.fasterxml.jackson.core.type.TypeReference<T> type)Decodes a byte array into the given type.static <T> TdecodeInto(byte[] input, Class<T> clazz)Decodes a byte array into the given class.static <T> TdecodeInto(String input, com.couchbase.client.core.deps.com.fasterxml.jackson.core.type.TypeReference<T> type)Decodes a String into the given type.static <T> TdecodeInto(String input, Class<T> clazz)Decodes a String into the given class.static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNodedecodeIntoTree(byte[] input)Decodes a byte array into a tree of JSON nodes.static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNodedecodeIntoTree(String input)Decodes a string into a tree of JSON nodes.static byte[]encodeAsBytes(Object input)Encodes the given input into a byte array, formatted non-pretty.static byte[]encodeAsBytesPretty(Object input)Encodes the given input into a byte array, formatted pretty.static StringencodeAsString(Object input)Encodes the given input into a String, formatted non-pretty.static StringencodeAsStringPretty(Object input)Encodes the given input into a String, formatted pretty.static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.ObjectReaderreader()Returns an ObjectReader for advanced use cases.static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.ObjectWriterwriter()Returns an ObjectWriter for advanced use cases.
-
-
-
Method Detail
-
encodeAsBytes
public static byte[] encodeAsBytes(Object input)
Encodes the given input into a byte array, formatted non-pretty.- Parameters:
input- the java object as input- Returns:
- the json encoded byte array.
-
encodeAsBytesPretty
public static byte[] encodeAsBytesPretty(Object input)
Encodes the given input into a byte array, formatted pretty.- Parameters:
input- the java object as input- Returns:
- the json encoded byte array.
-
encodeAsString
public static String encodeAsString(Object input)
Encodes the given input into a String, formatted non-pretty.- Parameters:
input- the java object as input- Returns:
- the json encoded String.
-
encodeAsStringPretty
public static String encodeAsStringPretty(Object input)
Encodes the given input into a String, formatted pretty.- Parameters:
input- the java object as input- Returns:
- the json encoded String.
-
decodeInto
public static <T> T decodeInto(byte[] input, Class<T> clazz)Decodes a byte array into the given class.- Type Parameters:
T- generic type used for inference.- Parameters:
input- the input byte array.clazz- the clazz which should be decoded into.- Returns:
- the created instance.
-
decodeInto
public static <T> T decodeInto(String input, Class<T> clazz)
Decodes a String into the given class.- Type Parameters:
T- generic type used for inference.- Parameters:
input- the input byte array.clazz- the clazz which should be decoded into.- Returns:
- the created instance.
-
decodeInto
public static <T> T decodeInto(byte[] input, com.couchbase.client.core.deps.com.fasterxml.jackson.core.type.TypeReference<T> type)Decodes a byte array into the given type.- Type Parameters:
T- generic type used for inference.- Parameters:
input- the input byte array.type- the type which should be decoded into.- Returns:
- the created instance.
-
decodeInto
public static <T> T decodeInto(String input, com.couchbase.client.core.deps.com.fasterxml.jackson.core.type.TypeReference<T> type)
Decodes a String into the given type.- Type Parameters:
T- generic type used for inference.- Parameters:
input- the input byte array.type- the type which should be decoded into.- Returns:
- the created instance.
-
decodeIntoTree
public static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode decodeIntoTree(byte[] input)
Decodes a byte array into a tree of JSON nodes.- Parameters:
input- the input byte array.- Returns:
- the created node.
-
decodeIntoTree
public static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode decodeIntoTree(String input)
Decodes a string into a tree of JSON nodes.- Parameters:
input- the input byte array.- Returns:
- the created node.
-
convertValue
public static <T> T convertValue(Object fromValue, Class<T> toValueType)
Converts an object to the requested type usingObjectMapper.convertValue(Object, Class).
-
convertValue
public static <T> T convertValue(Object fromValue, com.couchbase.client.core.deps.com.fasterxml.jackson.core.type.TypeReference<T> toValueTypeRef)
Converts an object to the requested type usingObjectMapper.convertValue(Object, TypeReference).
-
reader
public static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.ObjectReader reader()
Returns an ObjectReader for advanced use cases.
-
writer
public static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.ObjectWriter writer()
Returns an ObjectWriter for advanced use cases.
-
createObjectNode
public static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.node.ObjectNode createObjectNode()
Returns a new empty ObjectNode.
-
createArrayNode
public static com.couchbase.client.core.deps.com.fasterxml.jackson.databind.node.ArrayNode createArrayNode()
Returns a new empty ArrayNode.
-
-