- java.lang.Object
-
- com.gluonhq.connect.converter.OutputStreamOutputConverter<T>
-
- com.gluonhq.connect.converter.JsonOutputConverter<T>
-
- Type Parameters:
T
- the type of the object to convert to a JSON Object
- All Implemented Interfaces:
OutputConverter<T>
public class JsonOutputConverter<T> extends OutputStreamOutputConverter<T> implements OutputConverter<T>
An OutputConverter that converts an object into a JSON Object that is written to an OutputStream. The actual conversion to JSON is handled by using an instance ofJsonConverter
.
-
-
Constructor Summary
Constructors Constructor Description JsonOutputConverter(Class<T> targetClass)
Construct a new instance of a JsonOutputConverter that is able to convert objects of the specifiedtargetClass
into JSON Objects and write them into the OutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
write(T t)
Converts an object into a JSON Object that is written to the InputStream.-
Methods inherited from class com.gluonhq.connect.converter.OutputStreamOutputConverter
getOutputStream, setOutputStream
-
-
-
-
Constructor Detail
-
JsonOutputConverter
public JsonOutputConverter(Class<T> targetClass)
Construct a new instance of a JsonOutputConverter that is able to convert objects of the specifiedtargetClass
into JSON Objects and write them into the OutputStream.- Parameters:
targetClass
- The class defining the objects being converted into JSON.
-
-
Method Detail
-
write
public void write(T t)
Converts an object into a JSON Object that is written to the InputStream. If the specifiedtargetClass
in the constructor equals to JsonObject.class, then this method will cast the provided object into a JsonObject instance and write it directly to the OutputStream. Otherwise, aJsonConverter
will be used to convert the object into a JSON Object.- Specified by:
write
in interfaceOutputConverter<T>
- Parameters:
t
- The object to convert into a JSON Object that will be written to the OutputStream.
-
-