Package com.vaadin.server
Class JsonCodec
- java.lang.Object
-
- com.vaadin.server.JsonCodec
-
- All Implemented Interfaces:
Serializable
public class JsonCodec extends Object implements Serializable
Decoder for converting RPC parameters and other values from JSON in transfer between the client and the server and vice versa.- Since:
- 7.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
JsonCodec.BeanProperty
-
Constructor Summary
Constructors Constructor Description JsonCodec()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Object
decodeCustomType(Type targetType, JsonValue value, ConnectorTracker connectorTracker)
static Object
decodeInternalOrCustomType(Type targetType, JsonValue value, ConnectorTracker connectorTracker)
static Object
decodeInternalType(Type targetType, boolean restrictToInternalTypes, JsonValue encodedJsonValue, ConnectorTracker connectorTracker)
Decodes a value that is of an internal type.static EncodeResult
encode(Object value, JsonValue diffState, Type valueType, ConnectorTracker connectorTracker)
static Collection<JsonCodec.BeanProperty>
getProperties(Class<?> type)
static boolean
isInternalTransportType(String transportType)
static boolean
isInternalType(Type type)
static boolean
jsonEquals(JsonValue a, JsonValue b)
Compares two json values for deep equality.
-
-
-
Method Detail
-
isInternalTransportType
public static boolean isInternalTransportType(String transportType)
-
isInternalType
public static boolean isInternalType(Type type)
-
decodeInternalOrCustomType
public static Object decodeInternalOrCustomType(Type targetType, JsonValue value, ConnectorTracker connectorTracker)
-
decodeCustomType
public static Object decodeCustomType(Type targetType, JsonValue value, ConnectorTracker connectorTracker)
-
decodeInternalType
public static Object decodeInternalType(Type targetType, boolean restrictToInternalTypes, JsonValue encodedJsonValue, ConnectorTracker connectorTracker)
Decodes a value that is of an internal type.Ensures the encoded value is of the same type as target type.
Allows restricting collections so that they must be declared using generics. If this is used then all objects in the collection are encoded using the declared type. Otherwise only internal types are allowed in collections.
- Parameters:
targetType
- The type that should be returned by this methodvalueAndType
- The encoded value and type arrayapplication
- A reference to the applicationenforceGenericsInCollections
- true if generics should be enforce, false to only allow internal types in collections- Returns:
-
encode
public static EncodeResult encode(Object value, JsonValue diffState, Type valueType, ConnectorTracker connectorTracker)
-
getProperties
public static Collection<JsonCodec.BeanProperty> getProperties(Class<?> type) throws IntrospectionException
- Throws:
IntrospectionException
-
jsonEquals
public static boolean jsonEquals(JsonValue a, JsonValue b)
Compares two json values for deep equality. This is a helper for overcoming the fact thatJsonValue#equals(Object)
only does an identity check andJsonValue.jsEquals(JsonValue)
is defined to use JavaScript semantics where arrays and objects are equals only based on identity.- Parameters:
a
- the first json value to check, may not be nullb
- the second json value to check, may not be null- Returns:
true
if both json values are the same;false
otherwise- Since:
- 7.4
-
-