Aller au contenu principal

TJsonParser

Class

type TJsonParser = class

This class is used to parse JSON strings into TJson objects. Any objects created should be freed with the Free method.

Methods

constructor Create;

Creates a TJsonParser instance.

function Parse(const Text: WideString): TJson;

Parses the text input and returns the retrieved JSON value.

function ParseAnsi(const Ansi: AnsiString): TJson;

function ParseAnsi(const Ansi: TBytes): TJson;

function ParseAnsi(Stream: TStream): TJson;

Parses the ANSI encoded input and returns the retrieved JSON value.

function ParseAnsiFile(const FileName: string): TJson;

Parses the ANSI encoded file and returns the retrieved JSON value.

function ParseUtf8(const Ansi: AnsiString): TJson;

function ParseUtf8(const Ansi: TBytes): TJson;

function ParseUtf8(Stream: TStream): TJson;

Parses the UTF-8 encoded input and returns the retrieved JSON value.

function ParseUtf8File(const FileName: string): TJson;

Parses the UTF-8 encoded file and returns the retrieved JSON value.

procedure Free;

Used to release memory and dispose of the object.

Example

parser = TJsonParser.Create

try
json = parser.Parse("{}")
showmessage(json.ToString)
json.free
except
end try
parser.free |