JsonExtensions.Expect Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Expect(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. |
Expect<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. |
Expect(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.
public static void Expect (this Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.JsonToken expectedToken, params object[] expectedValues);
static member Expect : Newtonsoft.Json.JsonReader * Newtonsoft.Json.JsonToken * obj[] -> unit
<Extension()>
Public Sub Expect (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
Expect<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.
public static TValue Expect<TValue> (this Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.JsonToken expectedToken, params object[] expectedValues);
static member Expect : Newtonsoft.Json.JsonReader * Newtonsoft.Json.JsonToken * obj[] -> 'Value
<Extension()>
Public Function Expect(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
The value of the current JSON token, or default(TValue) if the current token has no value.
Applies to
Azure SDK for .NET