Package sk.antons.json
Interface JsonArray
-
- All Superinterfaces:
JsonValue
- All Known Implementing Classes:
JsonArrayImpl
public interface JsonArray extends JsonValue
Json array instance.- Author:
- antons
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JsonArrayadd(JsonValue value)Adds new element to json array.JsonArrayadd(JsonValue value, int index)Adds new element to json array at specified position.voidclear()Clears content of json array.JsonValuefirst()Reads first element of json array.JsonValueget(int index)Reads n'th item from json array.booleanisEmpty()Checks if this json array contains no value.JsonValuelast()Reads last element of json array.JsonValueremove(int index)Removes n'th element from json array.intsize()Size of json array.List<JsonValue>toList()Converts this instance to regulat list of values.-
Methods inherited from interface sk.antons.json.JsonValue
asArray, asBoolLiteral, asExpLiteral, asFracLiteral, asIntLiteral, asLiteral, asNullLiteral, asObject, asStringLiteral, asTemplateParam, copy, findAll, findAllLiterals, findFirst, findFirstLiteral, isArray, isBoolLiteral, isDescendantOf, isExpLiteral, isFracLiteral, isIntLiteral, isLiteral, isNullLiteral, isObject, isStringLiteral, name, parent, parentIndex, path, pathAsString, remove, replaceBy, toCompactString, toPrettyString
-
-
-
-
Method Detail
-
isEmpty
boolean isEmpty()
Checks if this json array contains no value.- Returns:
- true if json array is empty.
-
size
int size()
Size of json array.- Returns:
- size of json array.
-
clear
void clear()
Clears content of json array.
-
get
JsonValue get(int index)
Reads n'th item from json array.- Parameters:
index- order if returned item (first element has index=0)- Returns:
- element of json array at 'index' position
-
first
JsonValue first()
Reads first element of json array.- Returns:
- first element of json array or null if array is empty.
-
last
JsonValue last()
Reads last element of json array.- Returns:
- last element of json array or null if array is empty.
-
remove
JsonValue remove(int index)
Removes n'th element from json array.- Parameters:
index- position of element in json array which should be removed- Returns:
- removed element
-
add
JsonArray add(JsonValue value)
Adds new element to json array.- Parameters:
value- value to be added to the array. Should not be empty- Returns:
- this json array instance
-
add
JsonArray add(JsonValue value, int index)
Adds new element to json array at specified position.- Parameters:
value- value to be added to the array. Should not be emptyindex- position where value should be added;- Returns:
- this json array instance
-
-