Class BsonReader
- Namespace
- Newtonsoft.Json.Bson
- Assembly
- Newtonsoft.Json.dll
Represents a reader that provides fast, non-cached, forward-only access to serialized Json data.
public class BsonReader : JsonReader, IDisposable
- Inheritance
-
BsonReader
- Implements
- Inherited Members
Constructors
BsonReader(BinaryReader)
Initializes a new instance of the BsonReader class.
public BsonReader(BinaryReader reader)
Parameters
reader
BinaryReaderThe reader.
BsonReader(BinaryReader, bool, DateTimeKind)
Initializes a new instance of the BsonReader class.
public BsonReader(BinaryReader reader, bool readRootValueAsArray, DateTimeKind dateTimeKindHandling)
Parameters
reader
BinaryReaderThe reader.
readRootValueAsArray
boolif set to
true
the root object will be read as a JSON array.dateTimeKindHandling
DateTimeKindThe DateTimeKind used when reading DateTime values from BSON.
BsonReader(Stream)
Initializes a new instance of the BsonReader class.
public BsonReader(Stream stream)
Parameters
stream
StreamThe stream.
BsonReader(Stream, bool, DateTimeKind)
Initializes a new instance of the BsonReader class.
public BsonReader(Stream stream, bool readRootValueAsArray, DateTimeKind dateTimeKindHandling)
Parameters
stream
StreamThe stream.
readRootValueAsArray
boolif set to
true
the root object will be read as a JSON array.dateTimeKindHandling
DateTimeKindThe DateTimeKind used when reading DateTime values from BSON.
Properties
DateTimeKindHandling
Gets or sets the DateTimeKind used when reading DateTime values from BSON.
public DateTimeKind DateTimeKindHandling { get; set; }
Property Value
- DateTimeKind
The DateTimeKind used when reading DateTime values from BSON.
JsonNet35BinaryCompatibility
Gets or sets a value indicating whether binary data reading should compatible with incorrect Json.NET 3.5 written binary.
public bool JsonNet35BinaryCompatibility { get; set; }
Property Value
- bool
true
if binary data reading will be compatible with incorrect Json.NET 3.5 written binary; otherwise,false
.
ReadRootValueAsArray
Gets or sets a value indicating whether the root object will be read as a JSON array.
public bool ReadRootValueAsArray { get; set; }
Property Value
- bool
true
if the root object will be read as a JSON array; otherwise,false
.
Methods
Close()
Changes the JsonReader.State to Closed.
public override void Close()
Read()
Reads the next JSON token from the stream.
public override bool Read()
Returns
- bool
true if the next token was read successfully; false if there are no more tokens to read.
ReadAsBytes()
Reads the next JSON token from the stream as a Byte[].
public override byte[] ReadAsBytes()
Returns
- byte[]
A Byte[] or a null reference if the next JSON token is null.
ReadAsDateTimeOffset()
Reads the next JSON token from the stream as a Nullable<T>.
public override DateTimeOffset? ReadAsDateTimeOffset()
Returns
ReadAsDecimal()
Reads the next JSON token from the stream as a Nullable<T>.
public override decimal? ReadAsDecimal()
Returns
- decimal?
A Nullable<T>.
ReadAsInt32()
Reads the next JSON token from the stream as a Nullable<T>.
public override int? ReadAsInt32()
Returns
- int?
A Nullable<T>.