- java.lang.Object
-
- com.gluonhq.connect.converter.InputStreamInputConverter<T>
-
- com.gluonhq.connect.converter.JsonInputConverter<T>
-
- Type Parameters:
T
- the type of the object to convert the JSON Object into
- All Implemented Interfaces:
InputConverter<T>
public class JsonInputConverter<T> extends InputStreamInputConverter<T>
An InputConverter that converts a JSON Object read from an InputStream into an object. The actual conversion from JSON to an object is handled by an instance ofJsonConverter
.
-
-
Constructor Summary
Constructors Constructor Description JsonInputConverter(Class<T> targetClass)
Construct a new instance of a JsonInputConverter that is able to convert the data read from the InputStream into objects of the specifiedtargetClass
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
read()
Converts a JSON Object that is read from the InputStream into an object and returns it.-
Methods inherited from class com.gluonhq.connect.converter.InputStreamInputConverter
getInputStream, setInputStream
-
-
-
-
Constructor Detail
-
JsonInputConverter
public JsonInputConverter(Class<T> targetClass)
Construct a new instance of a JsonInputConverter that is able to convert the data read from the InputStream into objects of the specifiedtargetClass
.- Parameters:
targetClass
- The class defining the objects being converted from JSON.
-
-
Method Detail
-
read
public T read()
Converts a JSON Object that is read from the InputStream into an object and returns it. If the specifiedtargetClass
in the constructor equals to JsonObject.class, then this method will just return the read JSON object directly instead of running the conversion. Otherwise, aJsonConverter
will be used to convert the JSON Object into the final object to return.- Returns:
- An object converted from the JSON Object that was read from the InputStream.
-
-