com.vaadin.server.communication
Interface JSONSerializer<T>

All Known Implementing Classes:
DateSerializer

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, ConnectorTracker) and deserialize(Type, Object, ConnectorTracker) 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.

This is the server side interface, see com.vaadin.client.communication.JSONSerializer for the client side interface.

Since:
7.2
Author:
Vaadin Ltd

Method Summary
 T deserialize(java.lang.reflect.Type type, java.lang.Object jsonValue, ConnectorTracker connectorTracker)
          Creates and deserializes an object received from the client.
 java.lang.Object serialize(T value, ConnectorTracker connectorTracker)
          Serialize the given object into JSON.
 

Method Detail

deserialize

T deserialize(java.lang.reflect.Type type,
              java.lang.Object jsonValue,
              ConnectorTracker connectorTracker)
Creates and deserializes an object received from the client. Must be compatible with serialize(Object, ConnectorTracker) and also with the client side com.vaadin.client.communication.JSONSerializer.

The json parameter is of type Object as org.json JSON classes have no other common super class

Parameters:
type - The expected return type
jsonValue - the value from the JSON
connectorTracker - the connector tracker instance for the UI
Returns:
A deserialized object

serialize

java.lang.Object serialize(T value,
                           ConnectorTracker connectorTracker)
Serialize the given object into JSON. Must be compatible with #deserialize(Object, connectorTracker) and the client side com.vaadin.client.communication.JSONSerializer

Parameters:
value - The object to serialize
connectorTracker - The connector tracker instance for the UI
Returns:
A JSON serialized version of the object


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.