Class JsonNull
- All Implemented Interfaces:
JsonSerializable<JsonElement>
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonNullfromJson(JsonReader jsonReader) Deserializes a JSON null from a JsonReader.static JsonNullGets the instance of the JsonNull class.booleanisNull()Identifies if a JsonElement is of type JsonNull.toJson(JsonWriter jsonWriter) Writes the object to the passedJsonWriter.Convenience method for writing theJsonSerializableto a JSON string.Methods inherited from class com.azure.json.models.JsonElement
isArray, isBoolean, isNumber, isObject, isStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.azure.json.JsonSerializable
toJson, toJson, toJsonBytes
-
Method Details
-
getInstance
Gets the instance of the JsonNull class.- Returns:
- The JsonNull instance.
-
isNull
public boolean isNull()Identifies if a JsonElement is of type JsonNull.- Overrides:
isNullin classJsonElement- Returns:
- A boolean value of whether a JsonElement is null.
-
toJson
Description copied from interface:JsonSerializableWrites the object to the passedJsonWriter.The contract for writing JSON to
JsonWriteris that the object being written will handle opening and closing its own JSON object. So, for objects calling out to otherJsonSerializableobjects for serialization, they'll write the field name only then pass theJsonWriterto the otherJsonSerializableobject. This way objects writing JSON will be self-encapsulated for writing properly formatted JSON.- Parameters:
jsonWriter- Where the object's JSON will be written.- Returns:
- The
JsonWriterwhere the JSON was written. - Throws:
IOException- If the object fails to be written to thejsonWriter.
-
fromJson
Deserializes a JSON null 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.NULL, anIllegalStateExceptionwill be thrown. Otherwise,getInstance()will be called to return the deserialized JSON null.- Parameters:
jsonReader- The JsonReader to deserialize from.- Returns:
- The deserialized JSON null.
- Throws:
IOException- If an error occurs while deserializing the JSON null.IllegalStateException- If the current token is notJsonToken.NULL.
-
toJsonString
Description copied from interface:JsonSerializableConvenience method for writing theJsonSerializableto a JSON string.- Returns:
- The JSON string representing the object.
- Throws:
IOException- If the object fails to be written as a JSON string.
-