System.JSON.BSON.TBsonReader
Delphi
TBsonReader = class(TJsonReader)
C++
class PASCALIMPLEMENTATION TBsonReader : public System::Json::Readers::TJsonReader
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
class | public | System.JSON.BSON.pas System.JSON.BSON.hpp |
System.JSON.BSON | System.JSON.BSON |
Description
Class to read data serialized in BSON format.
To read BSON data:
- Create a BSON reader that reads data from a data stream.
- Call Read so that the reader moves to the first BSON 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.
- CurrentElementType indicates the BSON type of the value of the token.
- Value provides access to the value of the token. The type of a token and the BSON type of its value determines the method of Value that you must use to access the value of the token. For example, if TokenType is
PropertyName
and CurrentElementType isString
, 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 BSON 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
). - Reader provides access to the underlying binary reader that the BSON reader uses.
- 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.