- java.lang.Object
-
- io.github.nstdio.http.ext.spi.GsonJsonMapping
-
- All Implemented Interfaces:
JsonMapping
public class GsonJsonMapping extends java.lang.Object implements JsonMapping
-
-
Constructor Summary
Constructors Constructor Description GsonJsonMapping(com.google.gson.Gson gson)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tread(byte[] bytes, java.lang.Class<T> targetType)Reads JSON data from thebytesand creates mapped object of typetargetType.<T> Tread(byte[] bytes, java.lang.reflect.Type targetType)Reads JSON data from thebytesand creates mapped object of typetargetType.<T> Tread(java.io.InputStream in, java.lang.Class<T> targetType)Reads JSON data from theinand creates mapped object of typetargetType.<T> Tread(java.io.InputStream in, java.lang.reflect.Type targetType)Reads JSON data from theinand creates mapped object of typetargetType.voidwrite(java.lang.Object o, java.io.OutputStream os)Writes JSON representation ofoobject toosstream.
-
-
-
Method Detail
-
read
public <T> T read(java.io.InputStream in, java.lang.Class<T> targetType) throws java.io.IOExceptionDescription copied from interface:JsonMappingReads JSON data from theinand creates mapped object of typetargetType. Note thatinmight not be closed by the underlying implementation and caller should try to closein.- Specified by:
readin interfaceJsonMapping- Type Parameters:
T- The type of object to create.- Parameters:
in- The input source.targetType- The required type.- Returns:
- The object created from JSON.
- Throws:
java.io.IOException- When there is a JSON parsing or binding error or I/O error occurred.
-
read
public <T> T read(java.io.InputStream in, java.lang.reflect.Type targetType) throws java.io.IOExceptionDescription copied from interface:JsonMappingReads JSON data from theinand creates mapped object of typetargetType. Note thatinmight not be closed by the underlying implementation and caller should try to closein.- Specified by:
readin interfaceJsonMapping- Type Parameters:
T- The type of object to create.- Parameters:
in- The input source.targetType- The required type.- Returns:
- The object created from JSON.
- Throws:
java.io.IOException- When there is a JSON parsing or binding error or I/O error occurred.
-
read
public <T> T read(byte[] bytes, java.lang.Class<T> targetType) throws java.io.IOExceptionDescription copied from interface:JsonMappingReads JSON data from thebytesand creates mapped object of typetargetType.- Specified by:
readin interfaceJsonMapping- Type Parameters:
T- The type of object to create.- Parameters:
bytes- The input source.targetType- The required type.- Returns:
- The object created from JSON.
- Throws:
java.io.IOException- When there is a JSON parsing or binding error or I/O error occurred.
-
read
public <T> T read(byte[] bytes, java.lang.reflect.Type targetType) throws java.io.IOExceptionDescription copied from interface:JsonMappingReads JSON data from thebytesand creates mapped object of typetargetType.- Specified by:
readin interfaceJsonMapping- Type Parameters:
T- The type of object to create.- Parameters:
bytes- The input source.targetType- The required type.- Returns:
- The object created from JSON.
- Throws:
java.io.IOException- When there is a JSON parsing or binding error or I/O error occurred.
-
write
public void write(java.lang.Object o, java.io.OutputStream os) throws java.io.IOExceptionDescription copied from interface:JsonMappingWrites JSON representation ofoobject toosstream.- Specified by:
writein interfaceJsonMapping- Parameters:
o- The object to write.os- The output stream.- Throws:
java.io.IOException- When I/O error occurred.
-
-