Class JsonWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
Instances of JsonWriter
are created using an instance of JsonProvider
or using the utility methods
in JsonProviders
.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
close()
Closes the JSON stream.abstract JsonWriter
flush()
Flushes any un-flushed content written to this writer.abstract JsonWriteContext
Gets the currentwriting context
for the JSON object.final <T> JsonWriter
writeArray
(Iterable<T> array, WriteValueCallback<JsonWriter, T> elementWriterFunc) Writes a JSON array.final <T> JsonWriter
writeArray
(T[] array, WriteValueCallback<JsonWriter, T> elementWriterFunc) Writes a JSON array.final <T> JsonWriter
writeArrayField
(String fieldName, Iterable<T> array, WriteValueCallback<JsonWriter, T> elementWriterFunc) Writes a JSON array field.final <T> JsonWriter
writeArrayField
(String fieldName, T[] array, WriteValueCallback<JsonWriter, T> elementWriterFunc) Writes a JSON array field.abstract JsonWriter
writeBinary
(byte[] value) Writes a JSON binary value.final JsonWriter
writeBinaryField
(String fieldName, byte[] value) Writes a JSON binary field.abstract JsonWriter
writeBoolean
(boolean value) Writes a JSON boolean value (true
orfalse
).final JsonWriter
writeBoolean
(Boolean value) Writes a nullable JSON boolean value (true
,false
, ornull
).final JsonWriter
writeBooleanField
(String fieldName, boolean value) Writes a JSON boolean field.final JsonWriter
writeBooleanField
(String fieldName, Boolean value) Writes a nullable JSON boolean field.abstract JsonWriter
writeDouble
(double value) Writes a JSON double value.final JsonWriter
writeDoubleField
(String fieldName, double value) Writes a JSON double field.abstract JsonWriter
Writes a JSON end array (]
).abstract JsonWriter
Writes a JSON end object (}
).abstract JsonWriter
writeFieldName
(String fieldName) Writes a JSON field name ("fieldName":
).abstract JsonWriter
writeFloat
(float value) Writes a JSON float value.final JsonWriter
writeFloatField
(String fieldName, float value) Writes a JSON float field.abstract JsonWriter
writeInt
(int value) Writes a JSON int value.final JsonWriter
writeIntField
(String fieldName, int value) Writes a JSON int field.final JsonWriter
writeJson
(JsonSerializable<?> value) Writes aJsonSerializable
object.final JsonWriter
writeJsonField
(String fieldName, JsonSerializable<?> value) Writes aJsonSerializable
field.abstract JsonWriter
writeLong
(long value) Writes a JSON long value.final JsonWriter
writeLongField
(String fieldName, long value) Writes a JSON long field.final <T> JsonWriter
writeMap
(Map<String, T> map, WriteValueCallback<JsonWriter, T> valueWriterFunc) Writes a JSON map.final <T> JsonWriter
writeMapField
(String fieldName, Map<String, T> map, WriteValueCallback<JsonWriter, T> valueWriterFunc) Writes a JSON map field.abstract JsonWriter
Writes a JSON null.final <T> JsonWriter
writeNullableField
(String fieldName, T nullable, WriteValueCallback<JsonWriter, T> writerFunc) Writes a nullable JSON field.final JsonWriter
writeNullField
(String fieldName) Writes a JSON null field ("fieldName":null
).final JsonWriter
writeNumber
(Number value) Writes a nullable JSON number value.final JsonWriter
writeNumberField
(String fieldName, Number value) Writes a nullable JSON number field.final JsonWriter
writeRawField
(String fieldName, String value) Writes the passed field literally without any additional handling.abstract JsonWriter
writeRawValue
(String value) Writes the passed value literally without any additional handling.abstract JsonWriter
Writes a JSON start array ([
).final JsonWriter
writeStartArray
(String fieldName) Writes a JSON start array ([
) with a preceding field name.abstract JsonWriter
Writes a JSON start object ({
).final JsonWriter
writeStartObject
(String fieldName) Writes a JSON start object ({
) with a preceding field name.abstract JsonWriter
writeString
(String value) Writes a JSON String value.final JsonWriter
writeStringField
(String fieldName, String value) Writes a JSON String field.writeUntyped
(Object value) Writes the unknown typevalue
.writeUntypedField
(String fieldName, Object value) Writes the unknown typevalue
field.
-
Constructor Details
-
JsonWriter
public JsonWriter()Creates an instance ofJsonWriter
.
-
-
Method Details
-
getWriteContext
Gets the currentwriting context
for the JSON object.The writing context can help determine whether a write operation would be illegal.
The initial write context is
JsonWriteContext.ROOT
.- Returns:
- The current writing context.
-
close
Closes the JSON stream.If the
writing context
isn'tJsonWriteContext.COMPLETED
when this is called anIllegalStateException
will be thrown.During closing the implementation of
JsonWriter
must flush any un-flushed content.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IllegalStateException
- If theJsonWriter
is closed before thewriting context
isJsonWriteContext.COMPLETED
.IOException
- If the underlying content store fails to close.
-
flush
Flushes any un-flushed content written to this writer.It should be assumed that each write call won't flush any contents.
- Returns:
- The flushed JsonWriter object.
- Throws:
IOException
- If the underlying content fails to flush.
-
writeStartObject
Writes a JSON start object ({
).- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If JSON start object fails to be written.
-
writeStartObject
Writes a JSON start object ({
) with a preceding field name.This API is the equivalent of calling
writeFieldName(String)
andwriteStartObject()
, in that order.- Parameters:
fieldName
- The field name.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If eitherfieldName
or JSON start object fails to be written.
-
writeEndObject
Writes a JSON end object (}
).If the current writing context isn't an object an
IllegalStateException
will be thrown.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If JSON end object fails to be written.
-
writeStartArray
Writes a JSON start array ([
).- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If JSON start array fails to be written.
-
writeStartArray
Writes a JSON start array ([
) with a preceding field name.This API is the equivalent of calling
writeFieldName(String)
andwriteStartArray()
, in that order.- Parameters:
fieldName
- The field name.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If eitherfieldName
or JSON start array fails to be written.
-
writeEndArray
Writes a JSON end array (]
).- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If JSON end array fails to be written.
-
writeFieldName
Writes a JSON field name ("fieldName":
).- Parameters:
fieldName
- The field name.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- IffieldName
fails to be written.
-
writeJson
Writes aJsonSerializable
object.If
value
is nullJsonToken.NULL
will be written.This API is used instead of
writeJsonField(String, JsonSerializable)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.- Parameters:
value
-JsonSerializable
object to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If theJsonSerializable
fails to be written.
-
writeArray
public final <T> JsonWriter writeArray(T[] array, WriteValueCallback<JsonWriter, T> elementWriterFunc) throws IOExceptionWrites a JSON array.This API will begin by writing the start array (
[
) followed by all elements in the array using theelementWriterFunc
and finishing by writing the end array (]
).If
array
is nullJsonToken.NULL
will be written.This API is used instead of
writeArrayField(String, Object[], WriteValueCallback)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.- Type Parameters:
T
- The array element type.- Parameters:
array
- The array being written.elementWriterFunc
- The function that writes each element of the array.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IfelementWriterFunc
is null.IOException
- If the JSON array fails to be written, either the start or end array or an element write.
-
writeArray
public final <T> JsonWriter writeArray(Iterable<T> array, WriteValueCallback<JsonWriter, T> elementWriterFunc) throws IOExceptionWrites a JSON array.This API will begin by writing the start array (
[
) followed by all elements in the array using theelementWriterFunc
and finishing by writing the end array (]
).If
array
is nullJsonToken.NULL
will be written.This API is used instead of
writeArrayField(String, Iterable, WriteValueCallback)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.- Type Parameters:
T
- The array element type.- Parameters:
array
- The array being written.elementWriterFunc
- The function that writes each element of the array.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IfelementWriterFunc
is null.IOException
- If the JSON array fails to be written, either the start or end array or an element write.
-
writeMap
public final <T> JsonWriter writeMap(Map<String, T> map, WriteValueCallback<JsonWriter, throws IOExceptionT> valueWriterFunc) Writes a JSON map.This API will begin by writing the start object (
{
) followed by key-value fields in the map using thevalueWriterFunc
and finishing by writing the end object (}
).If
map
is nullJsonToken.NULL
will be written.This API is used instead of
writeMapField(String, Map, WriteValueCallback)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.- Type Parameters:
T
- The value element type.- Parameters:
map
- The map being written.valueWriterFunc
- The function that writes value of each key-value pair in the map.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IfvalueWriterFunc
is null.IOException
- If the JSON map fails to be written, either the start or end object or a key or value write.
-
writeBinary
Writes a JSON binary value.If
value
is nullJsonToken.NULL
will be written.This API is used instead of
writeBinaryField(String, byte[])
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.- Parameters:
value
- Binary value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the binaryvalue
fails to be written.
-
writeBoolean
Writes a JSON boolean value (true
orfalse
).This API is used instead of
writeBooleanField(String, boolean)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.For the nullable
Boolean
usewriteBoolean(Boolean)
.- Parameters:
value
- boolean value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the booleanvalue
fails to be written.
-
writeBoolean
Writes a nullable JSON boolean value (true
,false
, ornull
).If
value
is nullJsonToken.NULL
will be written.This API is used instead of
writeBooleanField(String, Boolean)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.For the primitive
boolean
usewriteBoolean(boolean)
.- Parameters:
value
- Boolean value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the Booleanvalue
fails to be written.
-
writeDouble
Writes a JSON double value.This API is used instead of
writeDoubleField(String, double)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.For the nullable
Double
usewriteNumber(Number)
.- Parameters:
value
- double value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the doublevalue
fails to be written.
-
writeFloat
Writes a JSON float value.This API is used instead of
writeFloatField(String, float)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.For the nullable
Float
usewriteNumber(Number)
.- Parameters:
value
- float value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the floatvalue
fails to be written.
-
writeInt
Writes a JSON int value.This API is used instead of
writeIntField(String, int)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.For the nullable
Integer
usewriteNumber(Number)
.- Parameters:
value
- int value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the intvalue
fails to be written.
-
writeLong
Writes a JSON long value.This API is used instead of
writeLongField(String, long)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.For the nullable
Long
usewriteNumber(Number)
.- Parameters:
value
- long value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the longvalue
fails to be written.
-
writeNull
Writes a JSON null.This API is used instead of
writeNullField(String)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If a JSON null fails to be written.
-
writeNumber
Writes a nullable JSON number value.If
value
is nullJsonToken.NULL
will be written.This API is used instead of
writeNumberField(String, Number)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.- Parameters:
value
- Number value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the Numbervalue
fails to be written.
-
writeString
Writes a JSON String value.If
value
is nullJsonToken.NULL
will be written.This API is used instead of
writeStringField(String, String)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.- Parameters:
value
- String value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the Stringvalue
fails to be written.
-
writeRawValue
Writes the passed value literally without any additional handling.Use this API when writing a String value that is already properly formatted JSON, such as a JSON string (
"\"string\""
), number ("42"
,"42.0"
), boolean ("true"
,"false"
), null ("null"
), array ("[\"string\", \"array\"]"
), or object ({"\"field\":\"value\""}
).This API is used instead of
writeRawField(String, String)
when the value needs to be written to the root of the JSON value, as an element in an array, or after a call towriteFieldName(String)
.- Parameters:
value
- The raw JSON value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- Ifvalue
is null.IOException
- If the rawvalue
fails to be written.
-
writeNullableField
public final <T> JsonWriter writeNullableField(String fieldName, T nullable, WriteValueCallback<JsonWriter, T> writerFunc) throws IOExceptionWrites a nullable JSON field.When the
value
is null this effectively is the same aswriteNullField(String)
. When thevalue
isn't null this will write the JSON field name and call thewriterFunc
that is supplied with the non-null nullable value and thisJsonWriter
to perform the write operation.- Type Parameters:
T
- Type of the nullable value.- Parameters:
fieldName
- The field name.nullable
- The nullable JSON value.writerFunc
- The non-null JSON value writer function.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
orwriterFunc
is null.IOException
- If thefieldName
or thenullable
fails to be written.
-
writeJsonField
public final JsonWriter writeJsonField(String fieldName, JsonSerializable<?> value) throws IOException Writes aJsonSerializable
field.Combines
writeFieldName(String)
andwriteJson(JsonSerializable)
to simplify adding a key-value to a JSON object.The field is only written when
value
isn't null, if a null field needs to be written usewriteNullableField(String, Object, WriteValueCallback)
.- Parameters:
fieldName
- The field name.value
-JsonSerializable
object to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If thefieldName
or theJsonSerializable
fails to be written.
-
writeArrayField
public final <T> JsonWriter writeArrayField(String fieldName, T[] array, WriteValueCallback<JsonWriter, T> elementWriterFunc) throws IOExceptionWrites a JSON array field.This API will begin by writing the field name and start array (
[
) followed by all elements in the array using theelementWriterFunc
and finishing by writing the end array (]
).The field is only written when
value
isn't null, if a null field needs to be written usewriteNullableField(String, Object, WriteValueCallback)
.Combines
writeFieldName(String)
andwriteArray(Object[], WriteValueCallback)
to simplify adding a key-value to a JSON object.- Type Parameters:
T
- The array element type.- Parameters:
fieldName
- The field name.array
- The array being written.elementWriterFunc
- The function that writes each element of the array.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
orelementWriterFunc
is null.IOException
- If thefieldName
or the JSON array fails to be written, either JSON start or end array or the element write.
-
writeArrayField
public final <T> JsonWriter writeArrayField(String fieldName, Iterable<T> array, WriteValueCallback<JsonWriter, T> elementWriterFunc) throws IOExceptionWrites a JSON array field.This API will begin by writing the field name and start array (
[
) followed by all elements in the array using theelementWriterFunc
and finishing by writing the end array (]
).The field is only written when
value
isn't null, if a null field needs to be written usewriteNullableField(String, Object, WriteValueCallback)
.Combines
writeFieldName(String)
andwriteArray(Iterable, WriteValueCallback)
to simplify adding a key-value to a JSON object.- Type Parameters:
T
- The array element type.- Parameters:
fieldName
- The field name.array
- The array being written.elementWriterFunc
- The function that writes each element of the array.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
orelementWriterFunc
is null.IOException
- If thefieldName
or the JSON array fails to be written, either JSON start or end array or the element write.
-
writeMapField
public final <T> JsonWriter writeMapField(String fieldName, Map<String, T> map, WriteValueCallback<JsonWriter, throws IOExceptionT> valueWriterFunc) Writes a JSON map field.This API will begin by writing the field name and start object (
{
) followed by key-value fields in the map using thevalueWriterFunc
and finishing by writing the end object (}
).The field is only written when
value
isn't null, if a null field needs to be written usewriteNullableField(String, Object, WriteValueCallback)
.Combines
writeFieldName(String)
andwriteMap(Map, WriteValueCallback)
to simplify adding a key-value to a JSON object.- Type Parameters:
T
- The value element type.- Parameters:
fieldName
- The field name.map
- The map being written.valueWriterFunc
- The function that writes each value of the map.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
orvalueWriterFunc
is null.IOException
- If thefieldName
or the JSON map fails to be written, either JSON start or end object or the key or value write.
-
writeBinaryField
Writes a JSON binary field.Combines
writeFieldName(String)
andwriteBinary(byte[])
to simplify adding a key-value to a JSON object.The field is only written when
value
isn't null, if a null field needs to be written usewriteNullableField(String, Object, WriteValueCallback)
.- Parameters:
fieldName
- The field name.value
- Binary value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or binaryvalue
fails to be written.
-
writeBooleanField
Writes a JSON boolean field.Combines
writeFieldName(String)
andwriteBoolean(boolean)
to simplify adding a key-value to a JSON object.- Parameters:
fieldName
- The field name.value
- boolean value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or booleanvalue
fails to be written.
-
writeBooleanField
Writes a nullable JSON boolean field.Combines
writeFieldName(String)
andwriteBoolean(Boolean)
to simplify adding a key-value to a JSON object.The field is only written when
value
isn't null, if a null field needs to be written usewriteNullableField(String, Object, WriteValueCallback)
.- Parameters:
fieldName
- The field name.value
- Boolean value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or Booleanvalue
fails to be written.
-
writeDoubleField
Writes a JSON double field.Combines
writeFieldName(String)
andwriteDouble(double)
to simplify adding a key-value to a JSON object.- Parameters:
fieldName
- The field name.value
- double value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or doublevalue
fails to be written.
-
writeFloatField
Writes a JSON float field.Combines
writeFieldName(String)
andwriteFloat(float)
to simplify adding a key-value to a JSON object.- Parameters:
fieldName
- The field name.value
- float value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or floatvalue
fails to be written.
-
writeIntField
Writes a JSON int field.Combines
writeFieldName(String)
andwriteInt(int)
to simplify adding a key-value to a JSON object.- Parameters:
fieldName
- The field name.value
- int value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or intvalue
fails to be written.
-
writeLongField
Writes a JSON long field.Combines
writeFieldName(String)
andwriteLong(long)
to simplify adding a key-value to a JSON object.- Parameters:
fieldName
- The field name.value
- long value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or longvalue
fails to be written.
-
writeNullField
Writes a JSON null field ("fieldName":null
).Combines
writeFieldName(String)
andwriteNull()
to simplify adding a key-value to a JSON object.- Parameters:
fieldName
- The field name.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or JSON null fails to be written.
-
writeNumberField
Writes a nullable JSON number field.Combines
writeFieldName(String)
andwriteNumber(Number)
to simplify adding a key-value to a JSON object.The field is only written when
value
isn't null, if a null field needs to be written usewriteNullableField(String, Object, WriteValueCallback)
.- Parameters:
fieldName
- The field name.value
- Number value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or Numbervalue
fails to be written.
-
writeStringField
Writes a JSON String field.Combines
writeFieldName(String)
andwriteString(String)
to simplify adding a key-value to a JSON object.The field is only written when
value
isn't null, if a null field needs to be written usewriteNullableField(String, Object, WriteValueCallback)
.- Parameters:
fieldName
- The field name.value
- String value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If either thefieldName
or Stringvalue
fails to be written.
-
writeRawField
Writes the passed field literally without any additional handling.Use this API when writing a String value that is already properly formatted JSON, such as a JSON string (
"\"string\""
), number ("42"
,"42.0"
), boolean ("true"
,"false"
), null ("null"
), array ("[\"string\", \"array\"]"
), or object ({"\"field\":\"value\""}
).Combines
writeFieldName(String)
andwriteRawValue(String)
to simplify adding a key-value to a JSON object.- Parameters:
fieldName
- The field name.value
- The raw JSON value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
orvalue
is null.IOException
- If either thefieldName
or rawvalue
fails to be written.
-
writeUntypedField
Writes the unknown typevalue
field.The following is how each
value
is handled (in this order):- null ->
writeNull()
short
->writeInt(int)
int
->writeInt(int)
long
->writeLong(long)
float
->writeFloat(float)
double
->writeDouble(double)
boolean
->writeBoolean(boolean)
CharSequence
->writeString(String)
char
->writeString(String)
JsonSerializable
->writeJson(JsonSerializable)
Object[]
->writeUntyped(Object)
for each elementIterable
->writeUntyped(Object)
for each elementMap
->writeUntyped(Object)
for each element where the key totoString
'dObject
-> empty JSON object ({}
)- All other values use the
toString
value withwriteString(String)
- Parameters:
fieldName
- The field name.value
- The value to write.- Returns:
- The updated JsonWriter object.
- Throws:
NullPointerException
- IffieldName
is null.IOException
- If eitherfieldName
or the untypedvalue
fails to be written.
- null ->
-
writeUntyped
Writes the unknown typevalue
.The following is how each
value
is handled (in this order):- null ->
writeNull()
short
->writeInt(int)
int
->writeInt(int)
long
->writeLong(long)
float
->writeFloat(float)
double
->writeDouble(double)
boolean
->writeBoolean(boolean)
CharSequence
->writeString(String)
char
->writeString(String)
JsonSerializable
->writeJson(JsonSerializable)
Object[]
->writeUntyped(Object)
for each elementIterable
->writeUntyped(Object)
for each elementMap
->writeUntyped(Object)
for each element where the key totoString
'dObject
-> empty JSON object ({}
)- All other values use the
toString
value withwriteString(String)
- Parameters:
value
- The value to write.- Returns:
- The updated JsonWriter object.
- Throws:
IOException
- If the untypedvalue
fails to be written.
- null ->
-