Table of Contents

Class JsonTextReader

Namespace
Newtonsoft.Json
Assembly
Newtonsoft.Json.dll

Represents a reader that provides fast, non-cached, forward-only access to serialized Json data.

public class JsonTextReader : JsonReader, IDisposable, IJsonLineInfo
Inheritance
JsonTextReader
Implements
Inherited Members

Constructors

JsonTextReader(TextReader)

Initializes a new instance of the JsonReader class with the specified TextReader.

public JsonTextReader(TextReader reader)

Parameters

reader TextReader

The TextReader containing the XML data to read.

Properties

LineNumber

Gets the current line number.

public int LineNumber { get; }

Property Value

int

The current line number or 0 if no line information is available (for example, HasLineInfo returns false).

LinePosition

Gets the current line position.

public int LinePosition { get; }

Property Value

int

The current line position or 0 if no line information is available (for example, HasLineInfo returns false).

Methods

Close()

Changes the state to closed.

public override void Close()

HasLineInfo()

Gets a value indicating whether the class can return line information.

public bool HasLineInfo()

Returns

bool

true if LineNumber and LinePosition can be provided; otherwise, false.

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

DateTimeOffset?

A DateTimeOffset.

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>.