System.JSON.Readers.TJsonTextReader
Delphi
TJsonTextReader = class(TJsonReader)
C++
class PASCALIMPLEMENTATION TJsonTextReader : public TJsonReader
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
class | public | System.JSON.Readers.pas System.JSON.Readers.hpp |
System.JSON.Readers | System.JSON.Readers |
Description
Class to read data serialized in JSON format.
To read JSON data:
- Create a JSON reader that reads data from a text reader.
- Call Read so that the reader moves to the first JSON token of the input data.
- TokenType indicates the type of the token. You can also use IsPrimitiveToken, IsStartToken or IsEndToken to determine whether or not the type of the token belongs to a specific set of token types.
- Value provides access to the value of the token. The type of a token determines the type of its value, which determines the method of Value that you must use to access the value of the token. For example, if TokenType is
PropertyName
, you must call Value.AsString to access a property name. - CurrentState indicates the state of the reader.
- LineNumber and LinePosition indicate the position within the input data where the reader is.
- Keep calling Read to go through all the JSON tokens of the input data. Read returns
False
when it reaches the end of the input data. - When you are finished reading the input data, you can either close or destroy the reader.
Instead of Read, you may alternatively use any of the following reading methods if you can anticipate the type of the next token:
TJsonTextReader also provides some additional features:
- CloseInput determines whether the reader closes the stream reader that provides the input data when you close the reader (
True
) or not (False
). - Rewind resets the reader to the state that it has when you create it, but it does not rewind the stream reader that provides the input data.