public class LfsGson
extends java.lang.Object
Gson
used by LFS servlets.Modifier and Type | Class and Description |
---|---|
(package private) static class |
LfsGson.Error
Wrapper class only used for serialization of error messages.
|
Modifier and Type | Field and Description |
---|---|
private static com.google.gson.Gson |
gson |
Constructor and Description |
---|
LfsGson() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
fromJson(java.io.Reader json,
java.lang.Class<T> classOfT)
Deserializes the Json read from the specified reader into an object of
the specified type.
|
static void |
toJson(java.lang.Object src,
java.lang.Appendable writer)
Serializes the specified object into its equivalent Json representation.
|
public static void toJson(java.lang.Object src, java.lang.Appendable writer) throws com.google.gson.JsonIOException
src
- the object for which Json representation is to be created. If
this is a String, it is wrapped in an instance of
LfsGson.Error
.writer
- Writer to which the Json representation needs to be writtencom.google.gson.JsonIOException
- if there was a problem writing to the writerGson.toJson(Object, Appendable)
public static <T> T fromJson(java.io.Reader json, java.lang.Class<T> classOfT) throws com.google.gson.JsonSyntaxException, com.google.gson.JsonIOException
T
- a T object.json
- reader producing json from which the object is to be
deserializedclassOfT
- specified type to deserializecom.google.gson.JsonIOException
- if there was a problem reading from the Readercom.google.gson.JsonSyntaxException
- if json is not a valid representation for an object of typeGson.fromJson(Reader, java.lang.reflect.Type)