JacksonJsonArray Class
- java.
lang. Object - com.
azure. json. models. JsonElement - com.
azure. core. serializer. json. jackson. models. JacksonJsonArray
- com.
- com.
public final class JacksonJsonArray
extends JsonElement
Implementation of JsonElement which is backed by Jackson's ArrayNode.
This allows for using Jackson's ArrayNode in places where JsonArray is required, meaning the Jackson ArrayNode doesn't need to be converted to azure-json's JsonArray.
Constructor Summary
| Constructor | Description |
|---|---|
| JacksonJsonArray() |
Creates a new JacksonJsonArray using the default JsonNodeFactory#instance ArrayNode. |
| JacksonJsonArray(ArrayNode array) |
Creates a new JacksonJsonArray using the provided ArrayNode. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
Jackson |
addElement(int index, JsonNode node)
Adds a Json |
|
Jackson |
addElement(JsonNode node)
Adds a Json |
|
static
Jackson |
fromJson(JsonReader jsonReader)
Deserializes a JSON array from a Json |
| com.fasterxml.jackson.databind.JsonNode |
getElement(int index)
Gets the Json |
| boolean | isArray() |
| com.fasterxml.jackson.databind.JsonNode |
removeElement(int index)
Removes the Json |
|
Jackson |
setElement(int index, JsonNode node)
Sets a specified Json |
| int |
size()
The number of elements in the Jackson |
|
Json |
toJson(JsonWriter jsonWriter) |
Methods inherited from JsonElement
Methods inherited from java.lang.Object
Constructor Details
JacksonJsonArray
public JacksonJsonArray()
Creates a new JacksonJsonArray using the default JsonNodeFactory#instance ArrayNode.
JacksonJsonArray
public JacksonJsonArray(ArrayNode array)
Creates a new JacksonJsonArray using the provided ArrayNode.
Parameters:
Method Details
addElement
public JacksonJsonArray addElement(int index, JsonNode node)
Adds a JsonNode to the JSON array at the specified index. This node will be inserted at the specified index and all elements at or after the index will be shifted.
Parameters:
Returns:
addElement
public JacksonJsonArray addElement(JsonNode node)
Adds a JsonNode to the JSON array. This node will be appended to the end of the array.
Parameters:
Returns:
fromJson
public static JacksonJsonArray 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 JsonReader#nextToken() will be called to begin reading.
After ensuring the JsonReader has begun reading, if the current token is not JsonToken#START_ARRAY, an IllegalStateException will be thrown. Otherwise, a JSON array representing the array will be created and returned.
Parameters:
Returns:
Throws:
getElement
public JsonNode getElement(int index)
Gets the JsonNode at the specified index from the JacksonJsonArray.
Parameters:
Returns:
Throws:
isArray
public boolean isArray()
Overrides:
JacksonJsonArray.isArray()removeElement
public JsonNode removeElement(int index)
Removes the JsonNode at the specified index from the JacksonJsonArray. This will shift all elements after the specified index.
Parameters:
Returns:
Throws:
setElement
public JacksonJsonArray setElement(int index, JsonNode node)
Sets a specified JsonNode object at a specified index within the JacksonJsonArray. This will replace the current JsonNode at the specified index with the newly specified JsonNode object.
Parameters:
Returns:
size
public int size()
The number of elements in the JacksonJsonArray.
Returns: