public class JsonSerializer extends Object
| Modifier and Type | Field and Description |
|---|---|
static Charset |
CHARSET
Constant for the loaded UTF-8 Charset.
|
static String |
CHARSET_STRING
The name of the UTF-8
CHARSET. |
| Constructor and Description |
|---|
JsonSerializer() |
| Modifier and Type | Method and Description |
|---|---|
static String |
objectToJson(Object object)
Converts the input POJO object to its JSON string.
|
static String |
toJson(Map<String,Object> mapObject)
Converts the input mapObject to its JSON String representation.
|
static Map<String,Object> |
toMap(InputStream jsonInputStream)
Converts the input JSON InputStream, to a Map<String, Object>.
|
static <T> T |
toPojo(InputStream jsonInputStream,
Class<T> pojoClass)
Converts the input JSON InputStream, to a POJO of the class specified as pojoClass.
|
public static final String CHARSET_STRING
CHARSET.public static final Charset CHARSET
public static Map<String,Object> toMap(InputStream jsonInputStream) throws IOException
jsonInputStream - the input stream to the JSON objectIOException - if trouble deserializingpublic static <T> T toPojo(InputStream jsonInputStream, Class<T> pojoClass) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T - the type of the POJOjsonInputStream - the input stream to the JSON objectpojoClass - the class to deserialize intocom.fasterxml.jackson.core.JsonParseException - if trouble parsingcom.fasterxml.jackson.databind.JsonMappingException - if trouble mappingIOException - if trouble deserializingpublic static String toJson(Map<String,Object> mapObject) throws com.fasterxml.jackson.core.JsonProcessingException
mapObject - the json's Map representationcom.fasterxml.jackson.core.JsonProcessingException - if an exception from the jackson serializerpublic static String objectToJson(Object object) throws com.fasterxml.jackson.core.JsonProcessingException
object - the object to serialize into a JSON string.com.fasterxml.jackson.core.JsonProcessingException - if there's trouble serializing object
to a JSON string.Copyright © 2023 HERE Europe B.V. All Rights Reserved.