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 |
|---|---|
| WriteBeginArray | Writes the beginning of a JSON array. |
| WriteEndArray | Writes the end of a JSON array. |
| WriteBeginObject | Writes the beginning of a JSON object. |
| WriteEndObject | Writes the end of a JSON object. |
| WriteName | Writes a property name in a JSON object. |
| WriteString | Writes a JSON string value, escaping special characters. |
| WriteRawString | Writes a raw string value as a JSON string without escaping special characters. |
| WriteBoolean | Writes a JSON boolean value. |
| WriteNull | Writes a JSON null value. |
| WriteDouble | Writes a JSON number value as a double-precision floating-point number. |
| WriteInteger | Writes a JSON number value as a 64-bit integer. |
| Flush | Flushes any buffered data to the underlying stream. |
| Close | Flushes and validates that the JSON document is complete. |
Properties
| Name | Description |
|---|---|
| Writer | Gets the underlying text writer used for output. |
| IndentLength | Gets or sets the number of spaces used for indentation. |