Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class Newtonsoft.​Json.​JsonTextReader
Assembly: Newtonsoft.Json
Inheritance: object → JsonReader → JsonTextReader
Implemented Interfaces
- System.​IDisposable Implemented by: JsonReader
- IJsonLineInfo
Represents a reader that provides fast, non-cached, forward-only access to JSON text data.
Properties
public
IArrayPool<​char>
ArrayPool
Gets or sets the reader's character buffer pool.
public
int
LineNumber
Gets the current line number.
public
int
LinePosition
Gets the current line position.
protected
State
CurrentState
Gets the current reader state.
public
bool
CloseInput
Gets or sets a value indicating whether the source should be closed when this reader is closed.
public
bool
SupportMultipleContent
Gets or sets a value indicating whether multiple pieces of JSON content can
be read from a continuous stream without erroring.
public
char
QuoteChar
Gets the quotation mark character used to enclose the value of a string.
public
DateTimeZoneHandling
DateTimeZoneHandling
Gets or sets how <see cref="T:System.DateTime" /> time zones are handled when reading JSON.
public
DateParseHandling
DateParseHandling
Gets or sets how date formatted strings, e.g. "\/Date(1198908717056)\/" and "2012-03-21T05:40Z", are parsed when reading JSON.
public
FloatParseHandling
FloatParseHandling
Gets or sets how floating point numbers, e.g. 1.0 and 9.9, are parsed when reading JSON text.
public
string
DateFormatString
Gets or sets how custom date formatted strings are parsed when reading JSON.
public
int?
MaxDepth
Gets or sets the maximum depth allowed when reading JSON. Reading past this depth will throw a <see cref="T:Newtonsoft.Json.JsonReaderException" /> .
public
JsonToken
TokenType
Gets the type of the current JSON token.
public
object
Value
Gets the text value of the current JSON token.
public
System.​Type
ValueType
Gets the .NET type for the current JSON token.
public
int
Depth
Gets the depth of the current token in the JSON document.
public
string
Path
Gets the path of the current JSON token.
Gets or sets the culture used when reading JSON. Defaults to <see cref="P:System.Globalization.CultureInfo.InvariantCulture" /> .
Methods
public
System.​Threading.​Tasks.​Task<​bool>
ReadAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the next JSON token from the source.
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous read. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns <c>true</c> if the next token was read successfully; <c>false</c> if there are no more tokens to read.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
Derived classes must override this method to get asynchronous behaviour. Otherwise it will
execute synchronously, returning an already-completed task.
public
System.​Threading.​Tasks.​Task<​bool?>
ReadAsBooleanAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the next JSON token from the source as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.Boolean" /> .
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous read. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns the <see cref="T:System.Nullable`1" /> of <see cref="T:System.Boolean" /> . This result will be <c>null</c> at the end of an array.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
Derived classes must override this method to get asynchronous behaviour. Otherwise it will
execute synchronously, returning an already-completed task.
public
System.​Threading.​Tasks.​Task<​byte[]>
ReadAsBytesAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the next JSON token from the source as a <see cref="T:System.Byte" /> [].
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous read. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns the <see cref="T:System.Byte" /> []. This result will be <c>null</c> at the end of an array.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
Derived classes must override this method to get asynchronous behaviour. Otherwise it will
execute synchronously, returning an already-completed task.
public
System.​Threading.​Tasks.​Task<​System.​DateTime?>
ReadAsDateTimeAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the next JSON token from the source as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.DateTime" /> .
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous read. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns the <see cref="T:System.Nullable`1" /> of <see cref="T:System.DateTime" /> . This result will be <c>null</c> at the end of an array.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
Derived classes must override this method to get asynchronous behaviour. Otherwise it will
execute synchronously, returning an already-completed task.
public
System.​Threading.​Tasks.​Task<​System.​DateTimeOffset?>
ReadAsDateTimeOffsetAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the next JSON token from the source as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.DateTimeOffset" /> .
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous read. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns the <see cref="T:System.Nullable`1" /> of <see cref="T:System.DateTimeOffset" /> . This result will be <c>null</c> at the end of an array.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
Derived classes must override this method to get asynchronous behaviour. Otherwise it will
execute synchronously, returning an already-completed task.
public
System.​Threading.​Tasks.​Task<​decimal?>
ReadAsDecimalAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the next JSON token from the source as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.Decimal" /> .
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous read. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns the <see cref="T:System.Nullable`1" /> of <see cref="T:System.Decimal" /> . This result will be <c>null</c> at the end of an array.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
Derived classes must override this method to get asynchronous behaviour. Otherwise it will
execute synchronously, returning an already-completed task.
public
System.​Threading.​Tasks.​Task<​double?>
ReadAsDoubleAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the next JSON token from the source as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.Double" /> .
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous read. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns the <see cref="T:System.Nullable`1" /> of <see cref="T:System.Double" /> . This result will be <c>null</c> at the end of an array.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
Derived classes must override this method to get asynchronous behaviour. Otherwise it will
execute synchronously, returning an already-completed task.
public
System.​Threading.​Tasks.​Task<​int?>
ReadAsInt32Async​(System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the next JSON token from the source as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.Int32" /> .
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous read. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns the <see cref="T:System.Nullable`1" /> of <see cref="T:System.Int32" /> . This result will be <c>null</c> at the end of an array.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
Derived classes must override this method to get asynchronous behaviour. Otherwise it will
execute synchronously, returning an already-completed task.
public
System.​Threading.​Tasks.​Task<​string>
ReadAsStringAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Asynchronously reads the next JSON token from the source as a <see cref="T:System.String" /> .
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous read. The <see cref="P:System.Threading.Tasks.Task`1.Result" />
property returns the <see cref="T:System.String" /> . This result will be <c>null</c> at the end of an array.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
Derived classes must override this method to get asynchronous behaviour. Otherwise it will
execute synchronously, returning an already-completed task.
public
bool
Read​()
Reads the next JSON token from the underlying <see cref="T:System.IO.TextReader" /> .
Returns <c>true</c> if the next token was read successfully; <c>false</c> if there are no more tokens to read.
public
int?
ReadAsInt32​()
Reads the next JSON token from the underlying <see cref="T:System.IO.TextReader" /> as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.Int32" /> .
Returns A <see cref="T:System.Nullable`1" /> of <see cref="T:System.Int32" /> . This method will return <c>null</c> at the end of an array.
public
System.​DateTime?
ReadAsDateTime​()
Reads the next JSON token from the underlying <see cref="T:System.IO.TextReader" /> as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.DateTime" /> .
Returns A <see cref="T:System.Nullable`1" /> of <see cref="T:System.DateTime" /> . This method will return <c>null</c> at the end of an array.
public
string
ReadAsString​()
Reads the next JSON token from the underlying <see cref="T:System.IO.TextReader" /> as a <see cref="T:System.String" /> .
Returns A <see cref="T:System.String" /> . This method will return <c>null</c> at the end of an array.
public
byte[]
ReadAsBytes​()
Reads the next JSON token from the underlying <see cref="T:System.IO.TextReader" /> as a <see cref="T:System.Byte" /> [].
Returns A <see cref="T:System.Byte" /> [] or <c>null</c> if the next JSON token is null. This method will return <c>null</c> at the end of an array.
public
bool?
ReadAsBoolean​()
Reads the next JSON token from the underlying <see cref="T:System.IO.TextReader" /> as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.Boolean" /> .
Returns A <see cref="T:System.Nullable`1" /> of <see cref="T:System.Boolean" /> . This method will return <c>null</c> at the end of an array.
ReadAsDateTimeOffset​()
Reads the next JSON token from the underlying <see cref="T:System.IO.TextReader" /> as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.DateTimeOffset" /> .
Returns A <see cref="T:System.Nullable`1" /> of <see cref="T:System.DateTimeOffset" /> . This method will return <c>null</c> at the end of an array.
public
decimal?
ReadAsDecimal​()
Reads the next JSON token from the underlying <see cref="T:System.IO.TextReader" /> as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.Decimal" /> .
Returns A <see cref="T:System.Nullable`1" /> of <see cref="T:System.Decimal" /> . This method will return <c>null</c> at the end of an array.
public
double?
ReadAsDouble​()
Reads the next JSON token from the underlying <see cref="T:System.IO.TextReader" /> as a <see cref="T:System.Nullable`1" /> of <see cref="T:System.Double" /> .
Returns A <see cref="T:System.Nullable`1" /> of <see cref="T:System.Double" /> . This method will return <c>null</c> at the end of an array.
public
void
Close​()
Changes the reader's state to <see cref="F:Newtonsoft.Json.JsonReader.State.Closed" /> .
If <see cref="P:Newtonsoft.Json.JsonReader.CloseInput" /> is set to <c>true</c> , the underlying <see cref="T:System.IO.TextReader" /> is also closed.
public
bool
HasLineInfo​()
Gets a value indicating whether the class can return line information.
Returns <c>true</c> if <see cref="P:Newtonsoft.Json.JsonTextReader.LineNumber" /> and <see cref="P:Newtonsoft.Json.JsonTextReader.LinePosition" /> can be provided; otherwise, <c>false</c> .
SkipAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Inherited from JsonReader
Asynchronously skips the children of the current token.
Returns A <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous operation.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
Remarks
The default behaviour is to execute synchronously, returning an already-completed task. Derived
classes can override this behaviour for true asychronousity.
public
void
Skip​()
Inherited from JsonReader
Skips the children of the current token.
protected
void
SetToken​(JsonToken newToken)
Inherited from JsonReader
Sets the current token.
newToken
The new token.
protected
void
SetToken​(JsonToken newToken,
object value)
Inherited from JsonReader
Sets the current token and value.
newToken
The new token.
value
The value.
protected
void
SetToken​(JsonToken newToken,
object value,
bool updateIndex)
Inherited from JsonReader
Sets the current token and value.
newToken
The new token.
value
The value.
updateIndex
A flag indicating whether the position index inside an array should be updated.
protected
void
SetStateBasedOnCurrent​()
Inherited from JsonReader
Sets the state based on current token type.
protected
void
Dispose​(bool disposing)
Inherited from JsonReader
Releases unmanaged and - optionally - managed resources.
disposing
<c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object