Class JsonTokenWriter

java.lang.Object
org.apache.juneau.marshall.json.JsonTokenWriter
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, RecordWriter, TokenWriter

public class JsonTokenWriter extends Object implements TokenWriter
Reference implementation of the public TokenWriter surface for the JSON format.

Emits RFC-8259-compliant JSON. Output style is driven by a small JsonTokenWriter.Settings bundle that mirrors the structurally-applicable subset of JsonSerializer.Builder's formatting flags: useWhitespace, maxIndent, quoteChar, escapeSolidus, and trimStrings. When opened via JsonSerializer.writeTokens(Object) the writer inherits the settings from the calling serializer; constructing the writer directly via JsonTokenWriter(Writer) uses JsonTokenWriter.Settings.DEFAULT (compact, double-quoted, RFC-8259 strict).

Notes:
  • This class is not thread safe.
  • The writer tracks just enough state to insert structural separators (, between array/object members and : between field names and values). It does not validate event ordering — emitting field twice in a row, for instance, throws.
  • The writer is purely structural; object swaps and @Schema annotations have no effect. Use the POJO databind path on JsonSerializer for those.