Interface JsonGenerator
public interface JsonGenerator
Represents interface to the underlying JAXB implementation, which handles the actual value serialization.
-
Method Summary
Modifier and TypeMethodDescriptionvoidWrites a closing marker of a JSON array value(the ']' character).voidWrites an opening marker of a JSON array value (the '[' character).voidwriteBoolean(boolean value) Outputs the given boolean value as a JSON boolean.voidwriteFieldName(String name) Writes a field name (JSON string surrounded by double quotes).voidOutputs JSON literalnullvalue.voidwriteNumber(Number number) Outputs the given numeric value as a JSON number.voidWrites a closing marker of a JSON object value (the '}' character).voidWrites a starting marker of a JSON object value (the '{' character).voidwriteString(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 literalnullvalue.This is usually not used, because
nullvalues 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
-