java.lang.Object
io.avaje.jex.core.json.JacksonJsonService
- All Implemented Interfaces:
JexExtension,JsonService
Jackson JsonService
-
Constructor Summary
ConstructorsConstructorDescriptionCreate with defaults for JacksonJacksonJsonService(com.fasterxml.jackson.databind.ObjectMapper mapper) Create with a Jackson instance that might have custom configuration. -
Method Summary
Modifier and TypeMethodDescription<T> TDeserializes a json byte[] into a Java object of the specified type.<T> TfromJson(Type type, InputStream is) Deserializes a json input stream and deserializes it into a Java object of the specified type.voidtoJson(Object bean, OutputStream os) **Writes a Java Object as JSON to an OutputStream**<T> voidtoJsonStream(Iterator<T> iterator, OutputStream os) Serializes a stream of Java objects into a JSON-Stream format, using thex-json-streammedia type.toJsonString(Object bean) **Writes a Java Object as a JSON string**
-
Constructor Details
-
JacksonJsonService
public JacksonJsonService()Create with defaults for Jackson -
JacksonJsonService
public JacksonJsonService(com.fasterxml.jackson.databind.ObjectMapper mapper) Create with a Jackson instance that might have custom configuration.
-
-
Method Details
-
fromJson
Description copied from interface:JsonServiceDeserializes a json input stream and deserializes it into a Java object of the specified type.- Specified by:
fromJsonin interfaceJsonService- Parameters:
type- the Type object of the desired typeis- the input stream containing the JSON data- Returns:
- the deserialized object
-
fromJson
Description copied from interface:JsonServiceDeserializes a json byte[] into a Java object of the specified type.- Specified by:
fromJsonin interfaceJsonService- Parameters:
type- the Type object of the desired typedata- the byte[] containing the JSON data- Returns:
- the deserialized object
-
toJson
Description copied from interface:JsonService**Writes a Java Object as JSON to an OutputStream**Serializes a Java object into JSON format and writes the resulting JSON to the specified output stream.
- Specified by:
toJsonin interfaceJsonService- Parameters:
bean- the Java object to be serializedos- the output stream to write the JSON data to
-
toJsonString
Description copied from interface:JsonService**Writes a Java Object as a JSON string**Serializes a Java object into JSON string format and writes the resulting JSON to the specified output stream.
- Specified by:
toJsonStringin interfaceJsonService- Parameters:
bean- the Java object to be serialized- Returns:
- the serialized JSON string
-
toJsonStream
Description copied from interface:JsonServiceSerializes a stream of Java objects into a JSON-Stream format, using thex-json-streammedia type. Each object in the stream is serialized as a separate JSON object, and the objects are separated by newlines.- Specified by:
toJsonStreamin interfaceJsonService- Parameters:
iterator- the stream of objects to be serializedos- the output stream to write the JSON-Stream data to
-