Interface JsonGenerator
public interface JsonGenerator
Represents interface to the underlying JAXB implementation, which handles the actual value serialization.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Writes a closing marker of a JSON array value(the ']' character).void
Writes an opening marker of a JSON array value (the '[' character).void
writeBoolean
(boolean value) Outputs the given boolean value as a JSON boolean.void
writeFieldName
(String name) Writes a field name (JSON string surrounded by double quotes).void
Outputs JSON literalnull
value.void
writeNumber
(Number number) Outputs the given numeric value as a JSON number.void
Writes a closing marker of a JSON object value (the '}' character).void
Writes a starting marker of a JSON object value (the '{' character).void
writeString
(String text) Outputs a String value.
-
Method Details
-
writeFieldName
Writes a field name (JSON string surrounded by double quotes).Can be used only in an object, when a field name is expected.
- Parameters:
name
- Field name to write- Throws:
IOException
- When JSON writing error occurs
-
writeObjectStart
Writes a starting marker of a JSON object value (the '{' character).Can be used anywhere except when a field name is expected.
- Throws:
IOException
- When JSON writing error occurs
-
writeObjectEnd
Writes a closing marker of a JSON object value (the '}' character).Can be used for closing objects either after a complete value or an object opening marker.
- Throws:
IOException
- When JSON writing error occurs
-
writeArrayStart
Writes an opening marker of a JSON array value (the '[' character).Can be used anywhere except when a field name is expected.
- Throws:
IOException
- When JSON writing error occurs
-
writeArrayEnd
Writes a closing marker of a JSON array value(the ']' character).Can be used when the innermost structured type is array.
- Throws:
IOException
- When JSON writing error occurs
-
writeNumber
Outputs the given numeric value as a JSON number.- Parameters:
number
- Number to write- Throws:
IOException
- When JSON writing error occurs
-
writeBoolean
Outputs the given boolean value as a JSON boolean.- Parameters:
value
- Value to write- Throws:
IOException
- When JSON writing error occurs
-
writeNull
Outputs JSON literalnull
value.This is usually not used, because
null
values are by default omitted by the serialization. But this can be configurable.- Throws:
IOException
- When JSON writing error occurs
-
writeString
Outputs a String value.Escaping will be done by the underlying implementation.
- Parameters:
text
- Text to write- Throws:
IOException
- When JSON writing error occurs
-