Package de.espirit.firstspirit.json
Interface JsonObject
- All Superinterfaces:
JsonElement<JsonObject>,de.espirit.firstspirit.json.JsonOutput
The root interface for json objects. Classes that implement this interface can be used as json objects
within the FirstSpirit json framework.
- Since:
- 5.2.191206
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonObjectcreate()Create a new emptyJsonObject.@Nullable JsonElement<?>Get the value with the specified key.booleanhasAttribute(@NotNull String name) Checks if thisobjectcontains an attribute with the given name.booleanisEmpty()Returnstrueif this json object contains no elements.@NotNull Collection<JsonPair>pairs()This method can be used to get all currently pairs that are part of the object.@NotNull JsonObjectThis method adds one pair to the object.@NotNull JsonObjectput(@NotNull String key, @NotNull JsonElement<?> value) This method adds one pair to the object.@NotNull JsonObjectput(@NotNull Collection<? extends JsonPair> pairs) This methods adds any kind of collection ofJsonPairs to the object.This methods removes the pair with the specified key.This methods removes the pair with the specified key.@Nullable JsonElement<?>Get the value for the specified path.Methods inherited from interface de.espirit.firstspirit.json.JsonElement
getValueMethods inherited from interface de.espirit.firstspirit.json.JsonOutput
json, writeTo
-
Field Details
-
PREFIX
static final char PREFIXThe default prefix of an object in json '{'.- Since:
- 5.2.191206
- See Also:
-
DELIMITER
static final char DELIMITERThe default delimiter of an object in json ','.- Since:
- 5.2.191206
- See Also:
-
SUFFIX
static final char SUFFIXThe default suffix of an object in json '}'.- Since:
- 5.2.191206
- See Also:
-
-
Method Details
-
create
Create a new emptyJsonObject.- Returns:
- a new
JsonObject - Since:
- 5.2.191206
-
hasAttribute
Checks if thisobjectcontains an attribute with the given name.- Parameters:
name- the name to check- Returns:
trueif this attribute is present, otherwisefalse- Since:
- 5.2.191206
-
pairs
This method can be used to get all currently pairs that are part of the object.- Returns:
- The
Listof all the pairs. - Since:
- 5.2.191206
-
put
This method adds one pair to the object.- Parameters:
pair- The pair that should be added (must not benull).- Returns:
- The object itself.
- Since:
- 5.2.191206
-
put
@NotNull @NotNull JsonObject put(@NotNull @NotNull String key, @NotNull @NotNull JsonElement<?> value) This method adds one pair to the object.- Parameters:
key- The key of the pair that should be added.value- The value of the pair that should be added.- Returns:
- The object itself.
- Since:
- 5.2.191206
-
put
This methods adds any kind of collection ofJsonPairs to the object.- Parameters:
pairs- The pairs that should be added (must not benull).- Returns:
- The object itself.
- Since:
- 5.2.191206
-
remove
This methods removes the pair with the specified key.- Parameters:
key- The key to remove- Returns:
- The object itself.
- Since:
- 5.2.191206
-
remove
This methods removes the pair with the specified key.- Parameters:
pair- The Pair to remove- Returns:
- The object itself.
- Since:
- 5.2.191206
-
get
Get the value with the specified key.- Parameters:
key- The key of the value which is requested.- Returns:
- The requested value or
nullif the key is unknown. - Since:
- 5.2.191206
-
resolve
Get the value for the specified path. E.g. for{ "a" : { "b": { "c": "x" }}}the path "a/b/c" specifies the value "x".- Parameters:
path- The path of the requested value- Returns:
- The requested value or
nullif any key in the path is unknown. - Since:
- 5.2.191206
-
isEmpty
boolean isEmpty()Returnstrueif this json object contains no elements.- Returns:
trueif this json object contains no elements, elsefalse- Since:
- 5.2.191206
-