JacksonJsonObject Class
- java.
lang. Object - com.
azure. json. models. JsonElement - com.
azure. core. serializer. json. jackson. models. JacksonJsonObject
- com.
- com.
public final class JacksonJsonObject
extends JsonElement
Implementation of JsonElement which is backed by Jackson's ObjectNode.
This allows for using Jackson's ObjectNode in places where JsonObject is required, meaning the Jackson ObjectNode doesn't need to be converted to azure-json's JsonObject.
Constructor Summary
| Constructor | Description |
|---|---|
| JacksonJsonObject() |
Creates a new JacksonJsonObject using the default JsonNodeFactory#instance ObjectNode. |
| JacksonJsonObject(ObjectNode object) |
Creates a new JacksonJsonObject using the provided ObjectNode. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
static
Jackson |
fromJson(JsonReader jsonReader)
Deserializes a JSON object from a Json |
| com.fasterxml.jackson.databind.JsonNode |
getProperty(String key)
Gets the Json |
| boolean | isObject() |
| com.fasterxml.jackson.databind.JsonNode |
removeProperty(String key)
Removes the Json |
|
Jackson |
setProperty(String key, JsonNode node)
Sets the Json |
| int |
size()
The number of properties in the JSON object. |
|
Json |
toJson(JsonWriter jsonWriter) |
Methods inherited from JsonElement
Methods inherited from java.lang.Object
Constructor Details
JacksonJsonObject
public JacksonJsonObject()
Creates a new JacksonJsonObject using the default JsonNodeFactory#instance ObjectNode.
JacksonJsonObject
public JacksonJsonObject(ObjectNode object)
Creates a new JacksonJsonObject using the provided ObjectNode.
Parameters:
Method Details
fromJson
public static JacksonJsonObject fromJson(JsonReader jsonReader)
Deserializes a JSON object 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_OBJECT, an IllegalStateException will be thrown. Otherwise, a JSON object representing the object will be created and returned.
Parameters:
Returns:
Throws:
getProperty
public JsonNode getProperty(String key)
Gets the JsonNode value corresponding to the specified key. If the key doesn't exist, null will be returned.
Parameters:
Returns:
isObject
public boolean isObject()
Overrides:
JacksonJsonObject.isObject()removeProperty
public JsonNode removeProperty(String key)
Removes the JsonNode value corresponding to the specified key. If the key doesn't exist, null will be returned.
Parameters:
Returns:
setProperty
public JacksonJsonObject setProperty(String key, JsonNode node)
Sets the JsonNode value corresponding to the specified key. If the key already exists, the value will be overwritten.
Parameters:
Returns:
size
public int size()
The number of properties in the JSON object.
Returns: