- All Superinterfaces:
JexExtension
- All Known Implementing Classes:
JacksonJsonService,JsonbJsonService
Service responsible for handling JSON-based request and response bodies.
- See Also:
-
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**default <E> voidtoJsonStream(Iterator<E> 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**
-
Method Details
-
toJson
**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.
- Parameters:
bean- the Java object to be serializedos- the output stream to write the JSON data to
-
toJsonString
**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.
- Parameters:
bean- the Java object to be serialized- Returns:
- the serialized JSON string
-
fromJson
Deserializes a json input stream and deserializes it into a Java object of the specified type.- Parameters:
type- the Type object of the desired typeis- the input stream containing the JSON data- Returns:
- the deserialized object
-
fromJson
Deserializes a json byte[] into a Java object of the specified type.- Parameters:
type- the Type object of the desired typedata- the byte[] containing the JSON data- Returns:
- the deserialized object
-
toJsonStream
Serializes 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.- Parameters:
iterator- the stream of objects to be serializedos- the output stream to write the JSON-Stream data to
-