JsonArray Class
- java.
lang. Object - com.
azure. json. models. JsonElement - com.
azure. json. models. JsonArray
- com.
- com.
public final class JsonArray
extends JsonElement
Model representing a JSON array.
Constructor Summary
| Constructor | Description |
|---|---|
| JsonArray() |
Default constructor. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
Json |
addElement(boolean element)
Adds a boolean element to the JSON array. |
|
Json |
addElement(int index, boolean element)
Adds a boolean element to the JSON array at the specified index. |
|
Json |
addElement(int index, JsonElement element)
Adds a Json |
|
Json |
addElement(int index, Number element)
Adds a number element to the JSON array at the specified index. |
|
Json |
addElement(int index, String element)
Adds a string element to the JSON array at the specified index. |
|
Json |
addElement(JsonElement element)
Adds a Json |
|
Json |
addElement(Number element)
Adds a number element to the JSON array. |
|
Json |
addElement(String element)
Adds a string element to the JSON array. |
|
static
Json |
fromJson(JsonReader jsonReader)
Deserializes a JSON array from a Json |
|
Json |
getElement(int index)
Gets the Json |
| boolean |
isArray()
Indicates whether the element is an array. |
|
Json |
removeElement(int index)
Removes the Json |
|
Json |
setElement(int index, boolean element)
Sets a specified boolean element at a specified index within the Json |
|
Json |
setElement(int index, JsonElement element)
Sets a specified Json |
|
Json |
setElement(int index, Number element)
Sets a specified number element at a specified index within the Json |
|
Json |
setElement(int index, String element)
Sets a specified string element at a specified index within the Json |
| int |
size()
The number of elements in the Json |
|
Json |
toJson(JsonWriter jsonWriter) |
| String | toJsonString() |
Methods inherited from JsonElement
Methods inherited from java.lang.Object
Constructor Details
JsonArray
public JsonArray()
Default constructor.
Method Details
addElement
public JsonArray addElement(boolean element)
Adds a boolean element to the JSON array. This element will be appended to the end of the array.
Parameters:
Returns:
addElement
public JsonArray addElement(int index, boolean element)
Adds a boolean element to the JSON array at the specified index. This element will be inserted at the specified index and all elements at or after the index will be shifted.
Parameters:
Returns:
addElement
public JsonArray addElement(int index, JsonElement element)
Adds a JsonElement to the JSON array at the specified index. This element will be inserted at the specified index and all elements at or after the index will be shifted.
Parameters:
Returns:
addElement
public JsonArray addElement(int index, Number element)
Adds a number element to the JSON array at the specified index. This element will be inserted at the specified index and all elements at or after the index will be shifted.
If the element is null this will be treated as a JSON null.
Parameters:
Returns:
addElement
public JsonArray addElement(int index, String element)
Adds a string element to the JSON array at the specified index. This element will be inserted at the specified index and all elements at or after the index will be shifted.
If the element is null this will be treated as a JSON null.
Parameters:
Returns:
addElement
public JsonArray addElement(JsonElement element)
Adds a JsonElement to the JSON array. This element will be appended to the end of the array.
Parameters:
Returns:
addElement
public JsonArray addElement(Number element)
Adds a number element to the JSON array. This element will be appended to the end of the array.
If the element is null this will be treated as a JSON null.
Parameters:
Returns:
addElement
public JsonArray addElement(String element)
Adds a string element to the JSON array. This element will be appended to the end of the array.
If the element is null this will be treated as a JSON null.
Parameters:
Returns:
fromJson
public static JsonArray fromJson(JsonReader jsonReader)
Deserializes a JSON array from a JsonReader.
If the JsonReader's current token is null, it is assumed the JsonReader hasn't begun reading and nextToken() will be called to begin reading.
After ensuring the JsonReader has begun reading, if the current token is not START_ARRAY, an IllegalStateException will be thrown. Otherwise, a JSON array representing the array will be created and returned.
Parameters:
Returns:
Throws:
getElement
public JsonElement getElement(int index)
Gets the JsonElement at the specified index from the JsonArray.
Parameters:
Returns:
Throws:
isArray
public boolean isArray()
Indicates whether the element is an array.
Overrides:
JsonArray.isArray()Returns:
removeElement
public JsonElement removeElement(int index)
Removes the JsonElement at the specified index from the JsonArray. This will shift all elements after the specified index.
Parameters:
Returns:
Throws:
setElement
public JsonArray setElement(int index, boolean element)
Sets a specified boolean element at a specified index within the JsonArray. This will replace the current JsonElement at the specified index with the newly specified boolean element.
Parameters:
Returns:
setElement
public JsonArray setElement(int index, JsonElement element)
Sets a specified JsonElement object at a specified index within the JsonArray. This will replace the current JsonElement at the specified index with the newly specified JsonElement object.
Parameters:
Returns:
setElement
public JsonArray setElement(int index, Number element)
Sets a specified number element at a specified index within the JsonArray. This will replace the current JsonElement at the specified index with the newly specified number element.
If the element is null this will be treated as a JSON null.
Parameters:
Returns:
setElement
public JsonArray setElement(int index, String element)
Sets a specified string element at a specified index within the JsonArray. This will replace the current JsonElement at the specified index with the newly specified string element.
If the element is null this will be treated as a JSON null.
Parameters:
Returns:
size
public int size()
The number of elements in the JsonArray.
Returns: