Table of Contents

TJsonWriter Class

Provides a forward-only, streaming JSON writer for generating JSON documents.

Remarks

Writes JSON tokens sequentially to an output stream. The writer maintains a scope stack to validate the JSON structure and supports optional indentation for pretty-printing. Write methods return Self to allow fluent method chaining.

Syntax

Unit: Bcl.Json.Writer

TJsonWriter = class(TObject);

Constructors

Name Description
Create Creates a JSON writer that outputs to the specified stream.

Methods

Name Description
Close Flushes and validates that the JSON document is complete.
Flush Flushes any buffered data to the underlying stream.
WriteBeginArray Writes the beginning of a JSON array.
WriteBeginObject Writes the beginning of a JSON object.
WriteBoolean Writes a JSON boolean value.
WriteDouble Writes a JSON number value as a double-precision floating-point number.
WriteEndArray Writes the end of a JSON array.
WriteEndObject Writes the end of a JSON object.
WriteInteger Writes a JSON number value as a 64-bit integer.
WriteName Writes a property name in a JSON object.
WriteNull Writes a JSON null value.
WriteRawString Writes a raw string value as a JSON string without escaping special characters.
WriteString Writes a JSON string value, escaping special characters.

Properties

Name Description
IndentLength Gets or sets the number of spaces used for indentation.
Writer Gets the underlying text writer used for output.