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.
CAUTION:
This class is still in development and may change drastically without any further notice.- Since:
- 5.2.191206
- See Also:
-
JsonOutput
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonObject
create()
Create a new emptyJsonObject
.@Nullable JsonElement<?>
Get the value with the specified key.boolean
hasAttribute
(@NotNull String name) Checks if thisobject
contains an attribute with the given name.boolean
isEmpty()
Returnstrue
if 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 JsonObject
This method adds one pair to the object.@NotNull JsonObject
put
(@NotNull String key, @NotNull JsonElement<?> value) This method adds one pair to the object.@NotNull JsonObject
put
(@NotNull Collection<? extends JsonPair> pairs) This methods adds any kind of collection ofJsonPair
s 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
getValue
Methods 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 thisobject
contains an attribute with the given name.- Parameters:
name
- the name to check- Returns:
true
if 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
List
of 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 ofJsonPair
s 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
null
if 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
null
if any key in the path is unknown. - Since:
- 5.2.191206
-
isEmpty
boolean isEmpty()Returnstrue
if this json object contains no elements.- Returns:
true
if this json object contains no elements, elsefalse
- Since:
- 5.2.191206
-