Class LfsGson

  • public class LfsGson
    extends Object
    Wrapper for Gson used by LFS servlets.
    • Constructor Detail

      • LfsGson

        public LfsGson()
    • Method Detail

      • toJson

        public static void toJson​(Object src,
                                  Appendable writer)
        Serializes the specified object into its equivalent Json representation.
        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 written
        Throws: - if there was a problem writing to the writer
        See Also:
        Gson.toJson(Object, Appendable)
      • fromJson

        public static <T> T fromJson​(Reader json,
                                     Class<T> classOfT)
        Deserializes the Json read from the specified reader into an object of the specified type.
        Type Parameters:
        T - a T object.
        json - reader producing json from which the object is to be deserialized
        classOfT - specified type to deserialize
        an Object of type T
        Throws: - if there was a problem reading from the Reader - if json is not a valid representation for an object of type
        See Also:
        Gson.fromJson(Reader, java.lang.reflect.Type)