Share via


JsonExtensions.ExpectAndAdvance Method

Definition

Overloads

ExpectAndAdvance(JsonReader, JsonToken, Object[])

Asserts that the given JSON reader is positioned on a token with the expected type. Optionally asserts that the value of the token matches a given expected value. If any of the assertions fail, this method throws a JsonSerializationException. Otherwise, this method attempts to advance the JSON reader to the next position.

ExpectAndAdvance<TValue>(JsonReader, JsonToken, Object[])

Asserts that the given JSON reader is positioned on a token with the expected type and retrieves the value of the token, if any. Optionally asserts that the value of the token matches a given expected value. If any of the assertions fail, this method throws a JsonSerializationException. Otherwise, this method attempts to advance the JSON reader to the next position.

ExpectAndAdvance(JsonReader, JsonToken, Object[])

Source:
JsonExtensions.cs

Asserts that the given JSON reader is positioned on a token with the expected type. Optionally asserts that the value of the token matches a given expected value. If any of the assertions fail, this method throws a JsonSerializationException. Otherwise, this method attempts to advance the JSON reader to the next position.

public static void ExpectAndAdvance(this Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.JsonToken expectedToken, params object[] expectedValues);
static member ExpectAndAdvance : Newtonsoft.Json.JsonReader * Newtonsoft.Json.JsonToken * obj[] -> unit
<Extension()>
Public Sub ExpectAndAdvance (reader As JsonReader, expectedToken As JsonToken, ParamArray expectedValues As Object())

Parameters

reader
Newtonsoft.Json.JsonReader

The JSON reader.

expectedToken
Newtonsoft.Json.JsonToken

The JSON token on which the reader is expected to be positioned.

expectedValues
Object[]

Optional; The expected possible values of the current JSON token.

Applies to

ExpectAndAdvance<TValue>(JsonReader, JsonToken, Object[])

Source:
JsonExtensions.cs

Asserts that the given JSON reader is positioned on a token with the expected type and retrieves the value of the token, if any. Optionally asserts that the value of the token matches a given expected value. If any of the assertions fail, this method throws a JsonSerializationException. Otherwise, this method attempts to advance the JSON reader to the next position.

public static TValue ExpectAndAdvance<TValue>(this Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.JsonToken expectedToken, params object[] expectedValues);
static member ExpectAndAdvance : Newtonsoft.Json.JsonReader * Newtonsoft.Json.JsonToken * obj[] -> 'Value
<Extension()>
Public Function ExpectAndAdvance(Of TValue) (reader As JsonReader, expectedToken As JsonToken, ParamArray expectedValues As Object()) As TValue

Type Parameters

TValue

The expected type of the value of the current JSON token.

Parameters

reader
Newtonsoft.Json.JsonReader

The JSON reader.

expectedToken
Newtonsoft.Json.JsonToken

The JSON token on which the reader is expected to be positioned.

expectedValues
Object[]

Optional; The expected possible values of the current JSON token.

Returns

TValue

The value of the JSON token before advancing the reader, or default(TValue) if the token has no value.

Applies to