Package sk.antons.json
Interface JsonArray
- All Superinterfaces:
JsonValue
- All Known Implementing Classes:
JsonArrayImpl
Json array instance.
- Author:
- antons
-
Method Summary
Modifier and TypeMethodDescriptionAdds new element to json array.Adds new element to json array at specified position.voidclear()Clears content of json array.first()Reads first element of json array.get(int index) Reads n'th item from json array.booleanisEmpty()Checks if this json array contains no value.last()Reads last element of json array.remove(int index) Removes n'th element from json array.intsize()Size of json array.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, find, find, findAll, findAllLiterals, findFirst, findFirstLiteral, isArray, isBoolLiteral, isDescendantOf, isExpLiteral, isFracLiteral, isIntLiteral, isLiteral, isNullLiteral, isObject, isStringLiteral, name, parent, parentIndex, path, pathAsString, remove, replaceBy, toCompactString, toPrettyString, writeCompact, writePretty
-
Method Details
-
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
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
Removes n'th element from json array.- Parameters:
index- position of element in json array which should be removed- Returns:
- removed element
-
add
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
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
-
toList
Converts this instance to regulat list of values.- Returns:
- list of json array values.
-