Package sk.antons.json
Interface JsonObject
- All Superinterfaces:
JsonValue
- All Known Implementing Classes:
JsonObjectImpl
Json object.
- Author:
- antons
-
Method Summary
Modifier and TypeMethodDescriptionAdds attribute ti this json object at last position.Adds attribute ti this json object at specified position.Values of all attributes with specidied nameattr(int index) Reads n'th attribute of this json objectReads first attribute of this json object with specified nameReads all attributes of this json object with specified namevoidclear()Clears all attributes from this json object.first()Returns value of first attribute.Value of first attribute with specidied nameintfirstIndex(String name) Index of first attribute with specidied namebooleanisEmpty()Checks if object has any attribute.last()Returns value of last attribute.Removes all values with specified name.removeAttr(int index) Removes n'th attribute from this json object.intsize()Size of json object.toList()Converts attributes to regular list.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 object has any attribute.- Returns:
- true if object has no attribute
-
size
int size()Size of json object.- Returns:
- number of attributes.
-
clear
void clear()Clears all attributes from this json object. -
attr
Reads n'th attribute of this json object- Parameters:
index- of the attribute which is read (first attribute has index=0)- Returns:
- attribute at index position
-
attr
Reads first attribute of this json object with specified name- Parameters:
name- of the attribute which is read (first attribute with the name will be returned)- Returns:
- first attribute with the name
-
attrs
Reads all attributes of this json object with specified name- Parameters:
name- of the attributes which is read (all attributes with the name will be returned)- Returns:
- all attributes with the name
-
removeAttr
Removes n'th attribute from this json object.- Parameters:
index- position of attribute which should be removed- Returns:
- remoced attribute
-
toList
List<JsonAttribute> toList()Converts attributes to regular list.- Returns:
-
first
JsonValue first()Returns value of first attribute.- Returns:
- first attribute value or null if json object is empty
-
last
JsonValue last()Returns value of last attribute.- Returns:
- last attribute value or null if json object is empty
-
add
Adds attribute ti this json object at last position.- Parameters:
name- name of the attributevalue- value of the attribute- Returns:
- this json object
-
add
Adds attribute ti this json object at specified position.- Parameters:
name- name of the attributevalue- value of the attributeindex- position of the attribute- Returns:
- this json object
-
firstIndex
Index of first attribute with specidied name- Parameters:
name- name of the attribute which should be found- Returns:
- index fist attribute with the name of null if it is not found
-
first
Value of first attribute with specidied name- Parameters:
name- name of the attribute which should be found- Returns:
- value of fist attribute with the name of null if it is not found
-
all
Values of all attributes with specidied name- Parameters:
name- name of the attributes which should be found- Returns:
- values of all attributes with the name
-
removeAll
Removes all values with specified name.- Parameters:
name- of attributes to be removed- Returns:
- this json object
-