Package blue.endless.jankson.api
Interface Marshaller
- All Known Implementing Classes:
MarshallerImpl
public interface Marshaller
-
Method Summary
Modifier and TypeMethodDescription<E> Emarshall(Class<E> clazz, JsonElement elem) Unpacks the provided JsonElement into a new object of typeclazz, making a best effort to unpack all the fields it can.<E> Emarshall(Type type, JsonElement elem) Unpacks the provided JsonElement into an object of the provided Type, and force-casts it to E.<E> EmarshallCarefully(Class<E> clazz, JsonElement elem) Unpacks the provided JsonElement in fail-fast mode.Turns a java object into its json intermediate representation.
-
Method Details
-
serialize
Turns a java object into its json intermediate representation. -
marshall
Unpacks the provided JsonElement into a new object of typeclazz, making a best effort to unpack all the fields it can. Any fields that cannot be unpacked will be left in the state the initializer and no-arg constructor leaves them in.Note: Consider using
marshallCarefully(Class, JsonElement)to detect errors first, and then calling this method as a fallback if an error is encountered.- Type Parameters:
E- The type of the object to create and deserialize- Parameters:
clazz- The class of the object to create and deserializeelem- json intermediate representation of the data to be unpacked.- Returns:
- A new object of the provided class that represents the data in the json provided.
-
marshall
Unpacks the provided JsonElement into an object of the provided Type, and force-casts it to E.- Type Parameters:
E- The type to force-cast to at the end- Parameters:
type- The type to deserialize toelem- json intermediate representation of the data to be unpacked.- Returns:
- A new object of the provided Type that represents the data in the json provided.
-
marshallCarefully
Unpacks the provided JsonElement in fail-fast mode. A detailed exception is thrown for any problem encountered during the unpacking process.- Type Parameters:
E- The type of the object to create and deserialize- Parameters:
clazz- The class of the object to create and deserializeelem- json intermediate representation of the data to be unpacked.- Returns:
- A new object of the provided class that represents the data in the json provided.
- Throws:
DeserializationException- if any problems are encountered unpacking the data.
-