Interface JSONDataType
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 Summary
Modifier and TypeMethodDescriptionReturns support for binary deltas.fromJsonString(String json) Parse a JSON string.readValue(byte[] bytes) Parse a value from CBOR-format binary.readValue(byte[] bytes, int offset, int length) Parse a value from CBOR-format binary.Parse a value from CBOR-format binary.Methods inherited from interface com.pushtechnology.diffusion.datatype.DataType
canReadAs, deltaType, deltaType, getTypeName, readAs, readAs, readAs, serializedBinaryDeltaType, toBytes, validate, validate, writeValue
-
Method Details
-
binaryDeltaType
DeltaType<JSON,BinaryDelta> binaryDeltaType()Returns support for binary deltas.Equivalent to calling
deltaType(BinaryDelta.class).- Specified by:
binaryDeltaTypein interfaceDataType<JSON>- Returns:
- the delta type, or null if none
-
fromJsonString
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()equalsjson.- Throws:
InvalidDataException- if json does not represent a single JSON value
-
readValue
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, anInvalidDataExceptionmay be thrown when aJSONmethod is called.- Specified by:
readValuein interfaceDataType<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 byteslength- length of the data within bytes- Throws:
IndexOutOfBoundsException- if eitheroffsetorlengthis negative, oroffset + length > bytes.length- See Also:
-
readValue
Parse a value from CBOR-format binary. Equivalent toreadValue(in, 0, in.length). -
readValue
Parse a value from CBOR-format binary. Equivalent toreadValue(bytes.toByteArray()).
-