public final class Json extends Object
Constructor and Description |
---|
Json() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
encodeAsBytes(Object obj)
Encode an object into a JSON value in bytes.
|
static String |
encodeAsString(Object obj)
Encode an object into a JSON string.
|
static Optional<JsonValue> |
parseBytes(byte[] input)
Parse a JSON byte array into a JsonValue if possible.
|
static <T> T |
parseBytesAs(byte[] input,
Class<T> clazz)
Parse a JSON byte array into a generic type T, or throws a JsonProcessingException in the case of exception.
|
static Optional<JsonValue> |
parseFull(String input)
Parse a JSON string into a JsonValue if possible.
|
static <T> T |
parseStringAs(String input,
Class<T> clazz)
Parse a JSON string into a generic type T, or throw JsonProcessingException in the case of
exception.
|
static JsonValue |
tryParseBytes(byte[] input) |
static JsonValue |
tryParseFull(String input)
Parse a JSON string into a JsonValue if possible.
|
public static Optional<JsonValue> parseFull(String input)
public static <T> T parseStringAs(String input, Class<T> clazz) throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingException
public static Optional<JsonValue> parseBytes(byte[] input) throws IOException
IOException
public static JsonValue tryParseBytes(byte[] input) throws IOException
IOException
public static <T> T parseBytesAs(byte[] input, Class<T> clazz) throws IOException
IOException
public static JsonValue tryParseFull(String input) throws com.fasterxml.jackson.core.JsonProcessingException
input
- a JSON string to parsecom.fasterxml.jackson.core.JsonProcessingException
- if failed to parsepublic static String encodeAsString(Object obj) throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingException
public static byte[] encodeAsBytes(Object obj) throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingException