Package com.codebarrel.api
Class JsonSupport
java.lang.Object
com.codebarrel.api.JsonSupport
Helper class to aid with JSON serialization/deserialization.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TconvertValue(Object input, com.fasterxml.jackson.core.type.TypeReference<?> typeRef) static <T> TconvertValue(Object input, Class<T> type) static byte[]toJsonBytes(Object json) static com.fasterxml.jackson.databind.JsonNodetoJsonNode(String in) static voidtoJsonStream(Object json, OutputStream out) static StringtoJsonString(Object json) static <T> List<T> static <T> Tstatic <T> TtoObject(InputStream in, Class<T> type) static <T> Tstatic <T> TConverts a JSON string to a specific type.
-
Constructor Details
-
JsonSupport
public JsonSupport()
-
-
Method Details
-
toJsonBytes
-
toJsonStream
-
convertValue
-
convertValue
public static <T> T convertValue(Object input, com.fasterxml.jackson.core.type.TypeReference<?> typeRef) -
toJsonString
-
toObject
-
toObject
-
toObject
-
toJsonNode
-
toObject
Converts a JSON string to a specific type. Callers should consider catching RuntimeException or JsonParseException since this will be thrown if the JSON is not parseable- Throws:
RuntimeException
-
toList
-