Table of Contents

Class JsonReader

Namespace
Newtonsoft.Json
Assembly
Newtonsoft.Json.dll

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

public abstract class JsonReader : IDisposable
Inheritance
JsonReader
Implements
Derived
Inherited Members

Constructors

JsonReader()

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

protected JsonReader()

Properties

CloseInput

Gets or sets a value indicating whether the underlying stream or TextReader should be closed when the reader is closed.

public bool CloseInput { get; set; }

Property Value

bool

true to close the underlying stream or TextReader when the reader is closed; otherwise false. The default is true.

Culture

Gets or sets the culture used when reading JSON. Defaults to InvariantCulture.

public CultureInfo Culture { get; set; }

Property Value

CultureInfo

CurrentState

Gets the current reader state.

protected JsonReader.State CurrentState { get; }

Property Value

JsonReader.State

The current reader state.

Depth

Gets the depth of the current token in the JSON document.

public virtual int Depth { get; }

Property Value

int

The depth of the current token in the JSON document.

QuoteChar

Gets the quotation mark character used to enclose the value of a string.

public virtual char QuoteChar { get; protected set; }

Property Value

char

TokenType

Gets the type of the current Json token.

public virtual JsonToken TokenType { get; }

Property Value

JsonToken

Value

Gets the text value of the current Json token.

public virtual object Value { get; }

Property Value

object

ValueType

Gets The Common Language Runtime (CLR) type for the current Json token.

public virtual Type ValueType { get; }

Property Value

Type

Methods

Close()

Changes the JsonReader.State to Closed.

public virtual void Close()

Dispose(bool)

Releases unmanaged and - optionally - managed resources

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Read()

Reads the next JSON token from the stream.

public abstract 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 abstract 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 abstract DateTimeOffset? ReadAsDateTimeOffset()

Returns

DateTimeOffset?

A Nullable<T>.

ReadAsDecimal()

Reads the next JSON token from the stream as a Nullable<T>.

public abstract decimal? ReadAsDecimal()

Returns

decimal?

A Nullable<T>.

ReadAsInt32()

Reads the next JSON token from the stream as a Nullable<T>.

public abstract int? ReadAsInt32()

Returns

int?

A Nullable<T>.

SetStateBasedOnCurrent()

Sets the state based on current token type.

protected void SetStateBasedOnCurrent()

SetToken(JsonToken)

Sets the current token.

protected void SetToken(JsonToken newToken)

Parameters

newToken JsonToken

The new token.

SetToken(JsonToken, object)

Sets the current token and value.

protected void SetToken(JsonToken newToken, object value)

Parameters

newToken JsonToken

The new token.

value object

The value.

Skip()

Skips the children of the current token.

public void Skip()