Package sk.antons.json
Interface JsonObject
-
- All Superinterfaces:
JsonValue
- All Known Implementing Classes:
JsonObjectImpl
public interface JsonObject extends JsonValue
Json object.- Author:
- antons
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JsonObjectadd(String name, JsonValue value)Adds attribute ti this json object at last position.JsonObjectadd(String name, JsonValue value, int index)Adds attribute ti this json object at specified position.List<JsonValue>all(String name)Values of all attributes with specidied nameJsonAttributeattr(int index)Reads n'th attribute of this json objectJsonAttributeattr(String name)Reads first attribute of this json object with specified nameList<JsonAttribute>attrs(String name)Reads all attributes of this json object with specified namevoidclear()Clears all attributes from this json object.JsonValuefirst()Returns value of first attribute.JsonValuefirst(String name)Value of first attribute with specidied nameintfirstIndex(String name)Index of first attribute with specidied namebooleanisEmpty()Checks if object has any attribute.JsonValuelast()Returns value of last attribute.JsonObjectremoveAll(String name)Removes all values with specified name.JsonAttributeremoveAttr(int index)Removes n'th attribute from this json object.intsize()Size of json object.List<JsonAttribute>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, 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 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
JsonAttribute attr(int index)
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
JsonAttribute attr(String name)
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
List<JsonAttribute> attrs(String name)
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
JsonAttribute removeAttr(int index)
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
JsonObject add(String name, JsonValue value)
Adds attribute ti this json object at last position.- Parameters:
name- name of the attributevalue- value of the attribute- Returns:
- this json object
-
add
JsonObject add(String name, JsonValue value, int index)
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
int firstIndex(String name)
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
JsonValue first(String name)
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
List<JsonValue> all(String name)
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
JsonObject removeAll(String name)
Removes all values with specified name.- Parameters:
name- of attributes to be removed- Returns:
- this json object
-
-