Package com.vaadin.client.flow.util
Class ClientJsonCodec
java.lang.Object
com.vaadin.client.flow.util.ClientJsonCodec
Static helpers for encoding and decoding JSON.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionstatic StateNodedecodeStateNode(StateTree tree, elemental.json.JsonValue json) Decodes a value as aStateNodeencoded on the server usingJacksonCodec.encodeWithTypeInfo(Object)if it's possible.static ObjectdecodeWithoutTypeInfo(elemental.json.JsonValue json) Decodes a value encoded on the server usingJacksonCodec.encodeWithoutTypeInfo(Object).static ObjectdecodeWithTypeInfo(StateTree tree, elemental.json.JsonValue json) Decodes a value encoded on the server usingJacksonCodec.encodeWithTypeInfo(Object).static elemental.json.JsonValueencodeWithoutTypeInfo(Object value) Helper for encoding any "primitive" value that is directly supported in JSON.
-
Method Details
-
decodeStateNode
Decodes a value as aStateNodeencoded on the server usingJacksonCodec.encodeWithTypeInfo(Object)if it's possible. Otherwise returnsnull.It does the same as
decodeWithTypeInfo(StateTree, JsonValue)for the encoded json value if the encoded object is aStateNodeexcept it returns the node itself instead of a DOM element associated with it.- Parameters:
tree- the state tree to use for resolving nodes and elementsjson- the JSON value to decode- Returns:
- the decoded state node if any
- See Also:
-
decodeWithTypeInfo
Decodes a value encoded on the server usingJacksonCodec.encodeWithTypeInfo(Object).- Parameters:
tree- the state tree to use for resolving nodes and elementsjson- the JSON value to decode- Returns:
- the decoded value
-
decodeWithoutTypeInfo
Decodes a value encoded on the server usingJacksonCodec.encodeWithoutTypeInfo(Object). This is a no-op in compiled JavaScript since the JSON representation can be used as-is, but some special handling is needed for tests running in the JVM.- Parameters:
json- the JSON value to convert- Returns:
- the decoded Java value
-
encodeWithoutTypeInfo
Helper for encoding any "primitive" value that is directly supported in JSON. Supported values types areString,Number,Boolean,JsonValue.nullis also supported.- Parameters:
value- the value to encode- Returns:
- the value encoded as JSON
-