Package com.github.mavolin.maxon
Class Maxon
- java.lang.Object
-
- com.github.mavolin.maxon.Maxon
-
-
Constructor Summary
Constructors Constructor Description Maxon()
Instantiates a newMaxon
converter with default settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAsJson(JsonValue jsonValue)
String
getAsJson(Object source)
Returns the JSON representation of the passedObject
.JsonValue
getAsJsonValue(Object source)
<T> T
getFromJson(JsonValue jsonValue, Class<T> clazz)
<T> T
getFromJson(String source, Class<T> clazz)
void
registerConverter(JsonConverter converter)
Registers aJsonConverter
.<T> void
registerParser(ObjectConverter<T> objectConverter, Class<T> clazz)
Registers aObjectConverter
associated with the specifiedClass
.
-
-
-
Method Detail
-
getAsJson
public String getAsJson(Object source)
Returns the JSON representation of the passedObject
.
-
getAsJsonValue
public JsonValue getAsJsonValue(Object source)
- Parameters:
source
- the source- Returns:
- the converted
Object
-
registerParser
public <T> void registerParser(ObjectConverter<T> objectConverter, Class<T> clazz)
Registers aObjectConverter
associated with the specifiedClass
. If there is already aJsonConverter
or aObjectConverter
registered the specifiedClass
, then the converter for thatClass
will be overwritten.- Type Parameters:
T
- the type parameter- Parameters:
objectConverter
- theObjectConverter
clazz
- theClass
theObjectConverter
can convert to and from
-
registerConverter
public void registerConverter(JsonConverter converter)
Registers aJsonConverter
. If there is already aJsonConverter
or aObjectConverter
registered for one of the convertibleClasses
, then the converter for thatClass
will be overwritten.- Parameters:
converter
- theJsonConverter
-
-