TJsonWriter
Class
type TJsonWriter = class
This class is used to push JSON data into a stream or file without creating an in-memory JSON object.
Methods
constructor Create(Stream: TStream; PrettyPrint: Boolean = True; UseTabChar: Boolean = False; TabSize: Integer = 2; Utf8: Boolean = true);
Creates a TJsonWriter instance that will be writing the JSON data into the Stream. Utf8 determines if the data will be in UTF-8 or wide chars.
constructor Create(const FileName: String; PrettyPrint: Boolean = True; UseTabChar: Boolean = False; TabSize: Integer = 2);
Creates a TJsonWriter instance that will be writing the JSON data into the specified file.
procedure Check;
Checks whether the JSON data was correctly created. Raises an exception if there are unpaired Begin/End Array/Objects or there is no data.
procedure BeginArray;
Starts a new array.
procedure BeginArray(const Name: WideString);
Starts a new array with the specified name.
procedure BeginObject;
Starts a new object.
procedure BeginObject(const Name: WideString);
Starts a new object with the specified name.
procedure EndArray;
Ends the array.
procedure EndObject;
Ends the object.
procedure WriteNull;
procedure WriteNull(const Name: WideString);
procedure Write(Value: Boolean);
procedure Write(const Name: WideString; Value: Boolean);
procedure Write(Value: Double);
procedure Write(const Name: WideString; Value: Double);
procedure Write(const Value: WideString);
procedure Write(const Name: WideString; const Value: WideString);
procedure Write(const Value: TDateTime; Offset: Integer);
procedure Write(const Name: WideString; const Value: TDateTime; Offset: Integer);
Writes the specified value with or without a name, as indicated.
Example |