Interface JSONCodec<T>

Type Parameters:
T - Normalized value type
All Superinterfaces:
TypeAwareCodec<T,Object,com.google.gson.stream.JsonWriter>

public sealed interface JSONCodec<T> extends TypeAwareCodec<T,Object,com.google.gson.stream.JsonWriter>
A codec capable of performing normalized value conversion with a JsonWriter.
  • Method Details

    • writeValue

      @Deprecated(since="13.0.3", forRemoval=true) default void writeValue(com.google.gson.stream.JsonWriter writer, T value) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Serialize specified value with specified JsonWriter..
      Specified by:
      writeValue in interface TypeAwareCodec<T,Object,com.google.gson.stream.JsonWriter>
      Parameters:
      writer - Write context
      value - Value in native format
      Throws:
      IOException - if the write fails
    • writeValue

      void writeValue(JSONValueWriter ctx, T value) throws IOException
      Serialize specified value with specified JSONValueWriter.
      Parameters:
      ctx - Write context
      value - Value in native format
      Throws:
      IOException - if the write fails
    • parseValue

      @Deprecated default T parseValue(Object ctx, String str)
      Deprecated.
      Use parseValue(String) instead.
      Parse a String representation into its native format..
      Specified by:
      parseValue in interface TypeAwareCodec<T,Object,com.google.gson.stream.JsonWriter>
      Parameters:
      ctx - Parse context
      str - String representation
      Returns:
      Value in native format
    • parseValue

      T parseValue(String str)
      Parse a String representation into its native format.
      Parameters:
      str - String representation
      Returns:
      Value in native format
      Throws:
      IllegalArgumentException - if the value does not parse or pass type validation
    • unparseValue

      @NonNull JSONValue unparseValue(T value)
      Return the JSONValue representation of a native value.
      Parameters:
      value - Value in native format
      Returns:
      A JSONValue
      Throws:
      IllegalArgumentException - if the value does not parse or pass type validation