Package org.eclipse.ditto.json
Class JsonFactory
java.lang.Object
org.eclipse.ditto.json.JsonFactory
The main entry point for the Eclipse Ditto JSON API.
It provides a lot of convenience methods.
Apart from
newArrayBuilder()
and newObjectBuilder()
all methods of this class return
immutable objects.-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonArray
createJsonArray
(List<JsonValue> jsonValueList, byte[] cborRepresentation) Creates aJsonArray
backed with an already serialized CBOR representation as the passed bytes.static JsonObject
createJsonObject
(Map<String, JsonField> jsonFieldMap, byte[] cborObjectRepresentation) Creates aJsonObject
backed with an already serialized CBOR representation as the passed bytes.static JsonFieldSelector
Returns a new empty JSON field selector.static JsonPointer
Returns an empty JSON pointer.static JsonValue
mergeJsonValues
(JsonValue jsonValue1, JsonValue jsonValue2) Merge two JSON values into one JSON value.static JsonArray
newArray()
Returns a new empty JSON array.static JsonArray
Creates a new JSON array from the given string.static JsonArrayBuilder
Returns a new mutable builder for aJsonArray
.static JsonArrayBuilder
newArrayBuilder
(Iterable<? extends JsonValue> values) Returns a new mutable builder for aJsonArray
which is already initialised with the given values.static JsonFieldDefinition<Boolean>
newBooleanFieldDefinition
(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains a boolean value.static JsonFieldDefinition<Double>
newDoubleFieldDefinition
(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains an double value.static JsonField
Returns a new JSON field based on the specified key value pair.static JsonField
newField
(JsonKey key, JsonValue value, JsonFieldDefinition<?> definition) Returns a new JSON field based on the specified key value pair and definition.static JsonFieldSelector
newFieldSelector
(CharSequence pointerString, CharSequence... furtherPointerStrings) Returns a new JSON field selector which is based on the givenJsonPointer
(s).static JsonFieldSelector
newFieldSelector
(Iterable<String> fieldSelectorStrings, JsonParseOptions options) Returns a new JSON field selector by parsing the given string.static JsonFieldSelector
newFieldSelector
(Iterable<JsonPointer> pointers) Returns a new JSON field selector which is based on the given set ofJsonPointer
s.static JsonFieldSelector
newFieldSelector
(String fieldSelectorString, JsonParseOptions options) Returns a new JSON field selector by parsing the given string.static JsonFieldSelector
newFieldSelector
(JsonFieldDefinition<?> fieldDefinition, JsonFieldDefinition<?>... furtherFieldDefinitions) Returns a new JSON field selector which is based on pointers of the givenJsonFieldDefinition
(s).static JsonFieldSelector
newFieldSelector
(JsonPointer pointer, JsonPointer... furtherPointers) Returns a new JSON field selector which is based on the givenJsonPointer
(s).static JsonFieldSelectorBuilder
Returns a new JSON field selector builder for building JSON field selectors.static JsonFieldDefinition<Integer>
newIntFieldDefinition
(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains an int value.static JsonFieldDefinition<JsonArray>
newJsonArrayFieldDefinition
(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains anJsonArray
value.static JsonFieldDefinition<JsonObject>
newJsonObjectFieldDefinition
(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains anJsonObject
value.static JsonFieldDefinition<JsonValue>
newJsonValueFieldDefinition
(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains anJsonValue
value.static JsonKey
newKey
(CharSequence keyValue) Returns JSON key for the given character sequence.static JsonFieldDefinition<Long>
newLongFieldDefinition
(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains an long value.static JsonObject
Returns an empty JSON object.static JsonObject
newObject
(byte[] jsonData) Creates a JSON object from the given byte array.static JsonObject
static JsonObject
Creates a JSON object from the given string.static JsonObject
Creates a JSON object from the given key-value pairs aka fields.static JsonObject
newObject
(JsonObject jsonObject1, JsonObject jsonObject2) Merge two JSON objects into one JSON object.static JsonObject
newObject
(JsonPointer path, JsonValue value) Creates a JSON object from the givenpath
andvalue
.static JsonObject
static JsonObjectBuilder
Returns a new mutable builder for aJsonObject
.static JsonObjectBuilder
newObjectBuilder
(Iterable<JsonField> jsonFields) Returns a new mutable builder for the specifiedJsonField
s.static JsonParseOptionsBuilder
Returns a new mutable builder forJsonParseOptions
.static JsonPatch
Returns a new JSON Patch created from the given string.static JsonPatch
newPatch
(JsonPatch.Operation operation, JsonPointer path, JsonValue value) Returns a new JSON Patch which can be used to specify modifications on JSON Objects.static JsonPointer
newPointer
(CharSequence slashDelimitedCharSequence) Parses the given string to obtain a new JSON pointer.static JsonPointer
newPointer
(JsonKey rootLevel, JsonKey... subLevels) Returns a new JSON pointer which consist of the specified hierarchical keys..static JsonFieldDefinition<String>
newStringFieldDefinition
(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains a String value.static JsonValue
newValue
(boolean value) Returns a JSON literal that represents the givenboolean
value.static JsonNumber
newValue
(double value) Returns a JSON number that represents the givendouble
value.static JsonNumber
newValue
(int value) Returns a JSON number that represents the givenint
value.static JsonNumber
newValue
(long value) Returns a JSON number that represents the givenlong
value.static JsonValue
Returns a JsonValue that represents the given Java string as JSON string.static JsonArray
Returns a JSON NULL literal which is typed as JSON array.static JsonValue
Returns a JSON literal which representsnull
.static JsonObject
Returns a JSON NULL literal which is typed as JSON object.static JsonFieldSelector
parseJsonFieldSelector
(String jsonFieldSelectorString) Parse a nullable string as JSON field selector.static JsonValue
Reads the entire input stream from the specified reader and parses it as JSON value.static JsonValue
Reads the given string and creates a JSON value based on the read data.
-
Method Details
-
newKey
Returns JSON key for the given character sequence. If the given key value is already a JSON key, this is immediately properly cast and returned.- Parameters:
keyValue
- the character sequence value of the JSON key to be created.- Returns:
- a new JSON key with
keyValue
as its value. - Throws:
NullPointerException
- ifkeyValue
isnull
.IllegalArgumentException
- ifkeyValue
is empty.
-
nullLiteral
Returns a JSON literal which representsnull
.- Returns:
- the
null
JSON literal.
-
newValue
Returns a JSON literal that represents the givenboolean
value.- Parameters:
value
- the value to get a JSON literal for.- Returns:
- a JSON literal that represents the given boolean value.
-
newValue
Returns a JSON number that represents the givenint
value.- Parameters:
value
- the value to get a JSON number for.- Returns:
- a JSON number that represents the given value.
-
newValue
Returns a JSON number that represents the givenlong
value.- Parameters:
value
- the value to get a JSON number for.- Returns:
- a JSON number that represents the given value.
-
newValue
Returns a JSON number that represents the givendouble
value.- Parameters:
value
- the value to get a JSON number for.- Returns:
- a JSON number that represents the given value.
-
newValue
Returns a JsonValue that represents the given Java string as JSON string. For example the Java string"foo"
would be"\"foo\""
as JSON string.- Parameters:
jsonString
- the string to get a JSON representation for.- Returns:
- a JSON value that represents the given string. If
jsonString
isnull
, a "null" object is returned. - Throws:
IllegalArgumentException
- ifjsonString
is empty.- See Also:
-
readFrom
Reads the given string and creates a JSON value based on the read data. The actual type of this JSON value is unknown but can be obtained by invoking theis...
methods.- Parameters:
jsonString
- the JSON document to read.- Returns:
- a JSON value representing the read document. This value can be a JSON literal, a JSON object and so on.
- Throws:
NullPointerException
- ifjsonString
is empty.JsonParseException
- ifjsonString
is empty or if it is no valid JSON.
-
readFrom
Reads the entire input stream from the specified reader and parses it as JSON value. The input stream is expected to contain a valid JSON value with optional whitespace padding.As characters are read in chunks and buffered internally it does not improve reading performance to wrap an existing reader in a
BufferedReader
.- Parameters:
reader
- the reader to read the JSON value from.- Returns:
- a JSON value which represents the read stream.
- Throws:
NullPointerException
- ifreader
isnull
.JsonParseException
- if an I/O error occurred or if the input is no valid JSON.
-
newObjectBuilder
Returns a new mutable builder for aJsonObject
.- Returns:
- a new JSON object builder.
-
newObjectBuilder
Returns a new mutable builder for the specifiedJsonField
s. The returned builder is already initialised with the data of the provided JSON object. This method is useful if an existing JSON object should be strongly modified but the amount of creating objects should be kept low at the same time.- Parameters:
jsonFields
- are the initial data of the returned builder.- Returns:
- a new JSON object builder with pre-filled data of
jsonFields
. - Throws:
NullPointerException
- ifjsonFields
isnull
.
-
newObject
Returns an empty JSON object.- Returns:
- an empty JSON object.
-
newObject
Creates a JSON object from the given string.- Parameters:
jsonString
- the string that represents the JSON object.- Returns:
- the JSON object that has been created from the string.
- Throws:
NullPointerException
- ifjsonString
isnull
.IllegalArgumentException
- ifjsonString
is empty.JsonParseException
- ifjsonString
does not contain a valid JSON object.
-
newObject
-
newObject
Creates a JSON object from the given byte array.- Parameters:
jsonData
- the byte array that represents the JSON object.- Returns:
- the JSON object that has been created from the data.
- Throws:
NullPointerException
- ifjsonData
isnull
.IllegalArgumentException
- ifjsonData
is empty.JsonParseException
- ifjsonData
does not contain a valid JSON object.- Since:
- 1.5.0
-
newObject
Creates a JSON object from the given key-value pairs aka fields.- Parameters:
fields
- the fields of the JSON object to be created.- Returns:
- a new JSON object based on the provided fields.
- Throws:
NullPointerException
- iffields
isnull
.
-
newObject
Creates a JSON object from the givenpath
andvalue
.- Parameters:
path
- the path where the given value will be setvalue
- the value that will be set at the given path- Returns:
- a new JSON object containing the given
value
at the givenpath
. - Throws:
NullPointerException
- ifpath
orvalue
isnull
.IllegalArgumentException
- ifpath
is empty andvalue
is not an object.- Since:
- 1.5.0
-
newObject
- Parameters:
jsonFields
- the json fields to create a new JsonObject from.- Returns:
- a null object if
jsonFields
is a null json object. Else this returns a new object containing the given {code jsonFields}.
-
newObject
Merge two JSON objects into one JSON object.- Parameters:
jsonObject1
- the json object to merge, overrides conflicting fields.jsonObject2
- the json object to merge.- Returns:
- returns a new object merged the given {code jsonObject1} and {code jsonObject2}.
- Since:
- 1.5.0
-
mergeJsonValues
Merge two JSON values into one JSON value. Implementation is conform to RFC 7396.- Parameters:
jsonValue1
- the json value to merge, overrides conflicting fields.jsonValue2
- the json value to merge.- Returns:
- returns a new value merged the given
jsonValue1
andjsonValue2
. - Since:
- 2.0.0
-
nullObject
Returns a JSON NULL literal which is typed as JSON object.- Returns:
- an object typed JSON NULL literal.
-
newArrayBuilder
Returns a new mutable builder for aJsonArray
.- Returns:
- a new JSON array builder.
-
newArrayBuilder
Returns a new mutable builder for aJsonArray
which is already initialised with the given values.- Parameters:
values
- the values of the JSON array to be created. This might be an existing JSON array as well.- Returns:
- a new JSON array builder.
- Throws:
NullPointerException
- ifvalues
isnull
.
-
newArray
Returns a new empty JSON array.- Returns:
- a new empty JSON array.
-
newArray
Creates a new JSON array from the given string.- Parameters:
jsonString
- the string that represents the JSON array.- Returns:
- the JSON array that has been created from the string.
- Throws:
NullPointerException
- ifjsonString
isnull
.IllegalArgumentException
- ifjsonString
is empty.JsonParseException
- ifjsonString
does not contain a valid JSON array.
-
nullArray
Returns a JSON NULL literal which is typed as JSON array.- Returns:
- an array typed JSON NULL literal.
-
newField
Returns a new JSON field based on the specified key value pair.- Parameters:
key
- the key of the field to be created.value
- the value of the field to be created.null
will be converted to the JSON NULL Literal.- Returns:
- a new JSON field containing the specified key value pair.
- Throws:
NullPointerException
- ifkey
is null;
-
newField
public static JsonField newField(JsonKey key, @Nullable JsonValue value, @Nullable JsonFieldDefinition<?> definition) Returns a new JSON field based on the specified key value pair and definition.- Parameters:
key
- the key of the field to be created.value
- the value of the field to be created.null
will be converted to the JSON NULL Literal.definition
- the definition of the field to be created.- Returns:
- a new JSON field containing the specified key value pair and definition.
- Throws:
NullPointerException
- ifkey
isnull
.
-
newPatch
public static JsonPatch newPatch(JsonPatch.Operation operation, JsonPointer path, @Nullable JsonValue value) Returns a new JSON Patch which can be used to specify modifications on JSON Objects.- Parameters:
operation
- the patch operation typepath
- a JSON Pointer specifying the path within the JSON Object on which the operation is definedvalue
- the value to be used for the specified operation on the given path- Returns:
- the new JSON Patch.
- Throws:
NullPointerException
- ifoperation
orpath
isnull
.
-
newPatch
Returns a new JSON Patch created from the given string.- Parameters:
jsonString
- the string representation of the JSON Patch object to be created.- Returns:
- the new JSON Patch.
- Throws:
NullPointerException
- ifjsonString
isnull
.IllegalArgumentException
- ifjsonString
is empty.JsonParseException
- ifjsonString
does not contain a valid JSON Patch JSON object.JsonMissingFieldException
- ifjsonString
did not containJsonPatch.JsonFields.OPERATION
orJsonPatch.JsonFields.PATH
.
-
emptyPointer
Returns an empty JSON pointer.- Returns:
- JSON pointer containing no JSON keys.
-
newPointer
Returns a new JSON pointer which consist of the specified hierarchical keys..- Parameters:
rootLevel
- the JSON key which is the root level of the JSON pointer to create.subLevels
- the JSON keys which form sub levels to the root level as well as to each other.- Returns:
- a new JSON pointer consisting of hierarchical JSON keys.
- Throws:
NullPointerException
- if any argument isnull
.
-
newPointer
Parses the given string to obtain a new JSON pointer. This method is the inverse ofJsonPointer.toString()
with one exception: both strings"/"
and""
lead to an empty pointer while the string representation of an empty string is always"/"
.To support tildes in JsonKeys, they have to be escaped with
"~0"
. For example, parsing the string"/foo/~0dum~0die~0dum/baz"
would result in a JsonPointer consisting of the JsonKeys"foo"
,"~dum~die~dum"
and"baz"
.
- Parameters:
slashDelimitedCharSequence
- a string representing a JSON pointer.- Returns:
- a new JSON pointer consisting of the JSON keys which were extracted from
slashDelimitedCharSequence
. - Throws:
NullPointerException
- ifslashDelimitedCharSequence
isnull
.JsonPointerInvalidException
- if the passedslashDelimitedCharSequence
contained double slashes.
-
newParseOptionsBuilder
Returns a new mutable builder forJsonParseOptions
.- Returns:
- the new JsonParseOptionsBuilder.
-
emptyFieldSelector
Returns a new empty JSON field selector.- Returns:
- a new empty JSON field selector.
-
newFieldSelector
public static JsonFieldSelector newFieldSelector(@Nullable String fieldSelectorString, JsonParseOptions options) Returns a new JSON field selector by parsing the given string. If the JSON field selector string isnull
or empty this means that no fields were selected thus this method returns an empty JSON field selector.For example, the field selector string
"thingId,attributes(acceleration,someData(foo,bar/baz)),features/key"
would lead to a JSON field selector which consists of the following JSON pointers:"thingId"
,"attributes/acceleration"
,"attributes/someData/foo"
,"attributes/someData/bar/baz"
,"features/key"
.
- Parameters:
fieldSelectorString
- string to be transformed into a JSON field selector object.options
- the JsonParseOptions to apply when parsing thefieldSelectorString
.- Returns:
- a new JSON field selector.
- Throws:
JsonFieldSelectorInvalidException
- iffieldSelectorString
is empty or iffieldSelectorString
does not contain a closing parenthesis ()
) for each opening parenthesis ((
).IllegalStateException
- iffieldSelectorString
cannot be decoded as UTF-8.
-
newFieldSelector
public static JsonFieldSelector newFieldSelector(Iterable<String> fieldSelectorStrings, JsonParseOptions options) Returns a new JSON field selector by parsing the given string. If the JSON field selector string isnull
or empty this means that no fields were selected thus this method returns an empty JSON field selector.For example, the field selector string
"thingId,attributes(acceleration,someData(foo,bar/baz)),features/key"
would lead to a JSON field selector which consists of the following JSON pointers:"thingId"
,"attributes/acceleration"
,"attributes/someData/foo"
,"attributes/someData/bar/baz"
,"features/key"
.
- Parameters:
fieldSelectorStrings
- strings to be transformed into a JSON field selector object.options
- the JsonParseOptions to apply when parsing thefieldSelectorString
.- Returns:
- a new JSON field selector.
- Throws:
JsonFieldSelectorInvalidException
- iffieldSelectorString
is empty or iffieldSelectorString
does not contain a closing parenthesis ()
) for each opening parenthesis ((
).IllegalStateException
- iffieldSelectorStrings
cannot be decoded as UTF-8.- Since:
- 3.3.0
-
newFieldSelector
Returns a new JSON field selector which is based on the given set ofJsonPointer
s. If the set of JSON pointers string is empty this means that no fields were selected thus this method returns an empty JSON field selector.- Parameters:
pointers
- the JSON pointers of the field selector to be created.- Returns:
- a new JSON field selector.
- Throws:
NullPointerException
- ifpointers
isnull
.IllegalArgumentException
- ifpointers
is empty.
-
newFieldSelector
public static JsonFieldSelector newFieldSelector(JsonPointer pointer, JsonPointer... furtherPointers) Returns a new JSON field selector which is based on the givenJsonPointer
(s).- Parameters:
pointer
- a JSON pointer of the field selector to be created.furtherPointers
- additional JSON pointers to form the field selector to be created by this method.- Returns:
- a new JSON field selector.
- Throws:
NullPointerException
- if any argument isnull
.
-
newFieldSelector
public static JsonFieldSelector newFieldSelector(CharSequence pointerString, CharSequence... furtherPointerStrings) Returns a new JSON field selector which is based on the givenJsonPointer
(s).- Parameters:
pointerString
- a JSON pointer of the field selector to be created.furtherPointerStrings
- additional JSON pointers to form the field selector to be created by this method.- Returns:
- a new JSON field selector.
- Throws:
NullPointerException
- if any argument isnull
.JsonPointerInvalidException
- if any passedpointerString
contained double slashes.
-
parseJsonFieldSelector
@Nullable public static JsonFieldSelector parseJsonFieldSelector(@Nullable String jsonFieldSelectorString) Parse a nullable string as JSON field selector. Return null if the string is null or contains a single comma.- Parameters:
jsonFieldSelectorString
- the string to parse.- Returns:
- the Json field selector.
- Since:
- 1.1.0
-
newFieldSelector
public static JsonFieldSelector newFieldSelector(JsonFieldDefinition<?> fieldDefinition, JsonFieldDefinition<?>... furtherFieldDefinitions) Returns a new JSON field selector which is based on pointers of the givenJsonFieldDefinition
(s).- Parameters:
fieldDefinition
- the JSON field definition of the returned field selector.furtherFieldDefinitions
- additional JSON field definitions of the returned field selector.- Returns:
- a new JSON field selector.
- Throws:
NullPointerException
- if any argument isnull
.
-
newFieldSelectorBuilder
Returns a new JSON field selector builder for building JSON field selectors.- Returns:
- the JSON field selector builder.
-
newStringFieldDefinition
public static JsonFieldDefinition<String> newStringFieldDefinition(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains a String value.- Parameters:
pointer
- a character sequence consisting of either a single JSON key or a slash delimited hierarchy of JSON keys aka JSON pointer.markers
- an optional array of markers which add user defined semantics to the defined JSON field.- Returns:
- the new JSON field definition.
- Throws:
NullPointerException
- if any argument isnull
.IllegalArgumentException
- ifpointer
is empty.
-
newBooleanFieldDefinition
public static JsonFieldDefinition<Boolean> newBooleanFieldDefinition(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains a boolean value.- Parameters:
pointer
- a character sequence consisting of either a single JSON key or a slash delimited hierarchy of JSON keys aka JSON pointer.markers
- an optional array of markers which add user defined semantics to the defined JSON field.- Returns:
- the new JSON field definition.
- Throws:
NullPointerException
- if any argument butmarkers
isnull
.IllegalArgumentException
- ifpointer
is empty.
-
newIntFieldDefinition
public static JsonFieldDefinition<Integer> newIntFieldDefinition(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains an int value.- Parameters:
pointer
- a character sequence consisting of either a single JSON key or a slash delimited hierarchy of JSON keys aka JSON pointer.markers
- an optional array of markers which add user defined semantics to the defined JSON field.- Returns:
- the new JSON field definition.
- Throws:
NullPointerException
- if any argument butmarkers
isnull
.IllegalArgumentException
- ifpointer
is empty.
-
newLongFieldDefinition
public static JsonFieldDefinition<Long> newLongFieldDefinition(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains an long value.- Parameters:
pointer
- a character sequence consisting of either a single JSON key or a slash delimited hierarchy of JSON keys aka JSON pointer.markers
- an optional array of markers which add user defined semantics to the defined JSON field.- Returns:
- the new JSON field definition.
- Throws:
NullPointerException
- if any argument butmarkers
isnull
.IllegalArgumentException
- ifpointer
is empty.
-
newDoubleFieldDefinition
public static JsonFieldDefinition<Double> newDoubleFieldDefinition(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains an double value.- Parameters:
pointer
- a character sequence consisting of either a single JSON key or a slash delimited hierarchy of JSON keys aka JSON pointer.markers
- an optional array of markers which add user defined semantics to the defined JSON field.- Returns:
- the new JSON field definition.
- Throws:
NullPointerException
- if any argument butmarkers
isnull
.IllegalArgumentException
- ifpointer
is empty.
-
newJsonArrayFieldDefinition
public static JsonFieldDefinition<JsonArray> newJsonArrayFieldDefinition(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains anJsonArray
value.- Parameters:
pointer
- a character sequence consisting of either a single JSON key or a slash delimited hierarchy of JSON keys aka JSON pointer.markers
- an optional array of markers which add user defined semantics to the defined JSON field.- Returns:
- the new JSON field definition.
- Throws:
NullPointerException
- if any argument butmarkers
isnull
.IllegalArgumentException
- ifpointer
is empty.
-
newJsonObjectFieldDefinition
public static JsonFieldDefinition<JsonObject> newJsonObjectFieldDefinition(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains anJsonObject
value.- Parameters:
pointer
- a character sequence consisting of either a single JSON key or a slash delimited hierarchy of JSON keys aka JSON pointer.markers
- an optional array of markers which add user defined semantics to the defined JSON field.- Returns:
- the new JSON field definition.
- Throws:
NullPointerException
- if any argument butmarkers
isnull
.IllegalArgumentException
- ifpointer
is empty.
-
newJsonValueFieldDefinition
public static JsonFieldDefinition<JsonValue> newJsonValueFieldDefinition(CharSequence pointer, JsonFieldMarker... markers) Returns a new definition of a JSON field which contains anJsonValue
value.- Parameters:
pointer
- a character sequence consisting of either a single JSON key or a slash delimited hierarchy of JSON keys aka JSON pointer.markers
- an optional array of markers which add user defined semantics to the defined JSON field.- Returns:
- the new JSON field definition.
- Throws:
NullPointerException
- if any argument butmarkers
isnull
.IllegalArgumentException
- ifpointer
is empty.
-
createJsonArray
public static JsonArray createJsonArray(List<JsonValue> jsonValueList, @Nullable byte[] cborRepresentation) Creates aJsonArray
backed with an already serialized CBOR representation as the passed bytes.This is a Ditto internal API is not intended for re-use. It therefore is not treated as API which is held binary compatible to previous versions.
- Parameters:
jsonValueList
- the JSON values to create the JsonArray from.cborRepresentation
- the already CBOR serialized representation of the JsonArray.- Returns:
- the created JsonArray.
- Since:
- 1.2.1
-
createJsonObject
public static JsonObject createJsonObject(Map<String, JsonField> jsonFieldMap, @Nullable byte[] cborObjectRepresentation) Creates aJsonObject
backed with an already serialized CBOR representation as the passed bytes.This is a Ditto internal API is not intended for re-use. It therefore is not treated as API which is held binary compatible to previous versions.
- Parameters:
jsonFieldMap
- the JSON fields to create the JsonObject from.cborObjectRepresentation
- the already CBOR serialized representation of the JsonObject.- Returns:
- the created JsonObject.
- Since:
- 1.2.1
-