Package com.vaadin.client.communication
Interface JSONSerializer<T>
-
- All Known Subinterfaces:
DiffJSONSerializer<T>
- All Known Implementing Classes:
Date_Serializer
,URLReference_Serializer
public interface JSONSerializer<T>
Implementors of this interface knows how to serialize an Object of a given type to JSON and how to deserialize the JSON back into an object.The
serialize(Object, ApplicationConnection)
anddeserialize(Type, JsonValue, ApplicationConnection)
methods must be symmetric so they can be chained and produce the original result (or an equal result).Each
JSONSerializer
implementation can handle an object of a single type - seeType.findSerializer()
.This is the client side interface, see com.vaadin.server.communication.JSONSerializer for the server side interface.
- Since:
- 7.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
deserialize(Type type, JsonValue jsonValue, ApplicationConnection connection)
Creates and deserializes an object received from the server.JsonValue
serialize(T value, ApplicationConnection connection)
Serialize the given object into JSON.
-
-
-
Method Detail
-
deserialize
T deserialize(Type type, JsonValue jsonValue, ApplicationConnection connection)
Creates and deserializes an object received from the server. Must be compatible withserialize(Object, ApplicationConnection)
and also with the server side JsonCodec.encode method.- Parameters:
type
- the type to deserializejsonValue
- JSON map from property name to property valueconnection
- the application connection providing the context- Returns:
- A deserialized object
-
serialize
JsonValue serialize(T value, ApplicationConnection connection)
Serialize the given object into JSON. Must be compatible withdeserialize(Type, JsonValue, ApplicationConnection)
and also with the server side JsonCodec.decodeCustomType method.- Parameters:
value
- The object to serializeconnection
- the application connection providing the context- Returns:
- A JSON serialized version of the object
-
-