Interface JSONDataType

All Superinterfaces:
DataType<JSON>

public interface JSONDataType extends DataType<JSON>
JSON data type.

For efficiency, the JSON value is serialized in binary form following the CBOR specification.

The implementation provides support for binary deltas.

Since:
5.7
Author:
DiffusionData Limited
See Also:
  • Method Details

    • binaryDeltaType

      DeltaType<JSON,BinaryDelta> binaryDeltaType()
      Returns support for binary deltas.

      Equivalent to calling deltaType(BinaryDelta.class).

      Specified by:
      binaryDeltaType in interface DataType<JSON>
      Returns:
      the delta type, or null if none
    • fromJsonString

      JSON fromJsonString(String json) throws InvalidDataException
      Parse a JSON string.

      Precision for numeric types is lost in the translation to the internal CBOR binary form and non-significant white space is not preserved. It is not guaranteed that fromJsonString(json).toJsonString() equals json.

      Throws:
      InvalidDataException - if json does not represent a single JSON value
    • readValue

      JSON readValue(byte[] bytes, int offset, int length) throws IndexOutOfBoundsException
      Parse a value from CBOR-format binary.

      JSON instances defer parsing of binary data until required so this method does not throw InvalidDataException. If the data is not valid, an InvalidDataException may be thrown when a JSON method is called.

      Specified by:
      readValue in interface DataType<JSON>
      Parameters:
      bytes - the binary data. The implementation re-uses the array to avoid copying. The caller must ensure the array is not modified.
      offset - start of the data within bytes
      length - length of the data within bytes
      Throws:
      IndexOutOfBoundsException - if either offset or length is negative, or offset + length > bytes.length
      See Also:
    • readValue

      JSON readValue(byte[] bytes)
      Parse a value from CBOR-format binary. Equivalent to readValue(in, 0, in.length).
      Specified by:
      readValue in interface DataType<JSON>
      Parameters:
      bytes - the binary data. The implementation re-uses the array to avoid copying. The caller must ensure the array is not modified.
    • readValue

      JSON readValue(Bytes bytes)
      Parse a value from CBOR-format binary. Equivalent to readValue(bytes.toByteArray()).
      Specified by:
      readValue in interface DataType<JSON>
      Parameters:
      bytes - the binary data