public class ObjectSerializer
extends java.lang.Object
JsonSerializable.toJson() and JsonSerializable.fromJson(JsonValue)
methods, which then need only a single line of code, where they call the appropriate methods, using an appropriate
Serializer to serialize the fields. See also Serialization for often used methods.| Constructor and Description |
|---|
ObjectSerializer(Serializer fieldSerializer) |
| Modifier and Type | Method and Description |
|---|---|
void |
loadFromJson(java.lang.Object object,
javax.json.JsonValue json,
java.util.List<java.lang.reflect.Field> fieldsToRestore)
Load the given object from Json, by initializing its fields according to the serialized json.
|
javax.json.JsonValue |
toJson(java.lang.Object object,
java.util.List<java.lang.reflect.Field> fieldsToStore)
Creates a JsonObject for the given object, where the object is persisted by mapping each of the fields to their values.
|
public ObjectSerializer(Serializer fieldSerializer)
public javax.json.JsonValue toJson(java.lang.Object object,
java.util.List<java.lang.reflect.Field> fieldsToStore)
Fields for various helper methods to get a list of fields.object - The object to be converted to Json.fieldsToStore - A list of fields to be stored in Json.public void loadFromJson(java.lang.Object object,
javax.json.JsonValue json,
java.util.List<java.lang.reflect.Field> fieldsToRestore)
object - The object with the fields to be initialized.json - The Json content describing the content of the fields.fieldsToRestore - The fields which must be restored to their original value.