Interface JsonObject

All Superinterfaces:
JsonElement<JsonObject>, de.espirit.firstspirit.json.JsonOutput

@NonExtendable @Experimental public interface JsonObject extends JsonElement<JsonObject>
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

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The default delimiter of an object in json ','.
    static final char
    The default prefix of an object in json '{'.
    static final char
    The default suffix of an object in json '}'.
  • Method Summary

    Modifier and Type
    Method
    Description
    static JsonObject
    Create a new empty JsonObject.
    @Nullable JsonElement<?>
    get(@NotNull String key)
    Get the value with the specified key.
    boolean
    hasAttribute(@NotNull String name)
    Checks if this object contains an attribute with the given name.
    boolean
    Returns true if this json object contains no elements.
    This method can be used to get all currently pairs that are part of the object.
    @NotNull JsonObject
    put(@NotNull JsonPair pair)
    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 of JsonPairs to the object.
    remove(@NotNull JsonPair pair)
    This methods removes the pair with the specified key.
    remove(@NotNull String key)
    This methods removes the pair with the specified key.
    @Nullable JsonElement<?>
    resolve(@NotNull String path)
    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 PREFIX
      The default prefix of an object in json '{'.
      Since:
      5.2.191206
      See Also:
    • DELIMITER

      static final char DELIMITER
      The default delimiter of an object in json ','.
      Since:
      5.2.191206
      See Also:
    • SUFFIX

      static final char SUFFIX
      The default suffix of an object in json '}'.
      Since:
      5.2.191206
      See Also:
  • Method Details

    • create

      static JsonObject create()
      Create a new empty JsonObject.
      Returns:
      a new JsonObject
      Since:
      5.2.191206
    • hasAttribute

      boolean hasAttribute(@NotNull @NotNull String name)
      Checks if this object contains an attribute with the given name.
      Parameters:
      name - the name to check
      Returns:
      true if this attribute is present, otherwise false
      Since:
      5.2.191206
    • pairs

      @NotNull @NotNull Collection<JsonPair> 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

      @NotNull @NotNull JsonObject put(@NotNull @NotNull JsonPair pair)
      This method adds one pair to the object.
      Parameters:
      pair - The pair that should be added (must not be null).
      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

      @NotNull @NotNull JsonObject put(@NotNull @NotNull Collection<? extends JsonPair> pairs)
      This methods adds any kind of collection of JsonPairs to the object.
      Parameters:
      pairs - The pairs that should be added (must not be null).
      Returns:
      The object itself.
      Since:
      5.2.191206
    • remove

      JsonObject remove(@NotNull @NotNull String key)
      This methods removes the pair with the specified key.
      Parameters:
      key - The key to remove
      Returns:
      The object itself.
      Since:
      5.2.191206
    • remove

      JsonObject remove(@NotNull @NotNull JsonPair pair)
      This methods removes the pair with the specified key.
      Parameters:
      pair - The Pair to remove
      Returns:
      The object itself.
      Since:
      5.2.191206
    • get

      @Nullable @Nullable JsonElement<?> get(@NotNull @NotNull String key)
      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

      @Nullable @Nullable JsonElement<?> resolve(@NotNull @NotNull String path)
      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()
      Returns true if this json object contains no elements.
      Returns:
      true if this json object contains no elements, else false
      Since:
      5.2.191206