Class ClientJsonCodec

java.lang.Object
com.vaadin.client.flow.util.ClientJsonCodec

public class ClientJsonCodec extends Object
Static helpers for encoding and decoding JSON.
Since:
1.0
Author:
Vaadin Ltd
  • Method Details

    • decodeStateNode

      public static StateNode decodeStateNode(StateTree tree, elemental.json.JsonValue json)
      Decodes a value as a StateNode encoded on the server using JacksonCodec.encodeWithTypeInfo(Object) if it's possible. Otherwise returns null.

      It does the same as decodeWithTypeInfo(StateTree, JsonValue) for the encoded json value if the encoded object is a StateNode except it returns the node itself instead of a DOM element associated with it.

      Parameters:
      tree - the state tree to use for resolving nodes and elements
      json - the JSON value to decode
      Returns:
      the decoded state node if any
      See Also:
    • decodeWithTypeInfo

      public static Object decodeWithTypeInfo(StateTree tree, elemental.json.JsonValue json)
      Decodes a value encoded on the server using JacksonCodec.encodeWithTypeInfo(Object).
      Parameters:
      tree - the state tree to use for resolving nodes and elements
      json - the JSON value to decode
      Returns:
      the decoded value
    • decodeWithoutTypeInfo

      public static Object decodeWithoutTypeInfo(elemental.json.JsonValue json)
      Decodes a value encoded on the server using JacksonCodec.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

      public static elemental.json.JsonValue encodeWithoutTypeInfo(Object value)
      Helper for encoding any "primitive" value that is directly supported in JSON. Supported values types are String, Number, Boolean, JsonValue. null is also supported.
      Parameters:
      value - the value to encode
      Returns:
      the value encoded as JSON