JsonExtensions Class

Definition

Defines extension methods for various JSON.NET types that make it easier to implement a custom JsonConverter.

public static class JsonExtensions
type JsonExtensions = class
Public Module JsonExtensions
Inheritance
JsonExtensions

Methods

Advance(JsonReader)

Advances the given JSON reader, or throws a JsonSerializationException if it cannot be advanced.

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.

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.

IsNumber(JToken)

Indicates whether or not the given JSON token is a numeric literal.

IsString(JToken, String)

Indicates whether or not the given JSON token matches the expected string.

IsValid(JObject, IEnumerable<String>, Func<JProperty,Boolean>)

Validates the properties of the given JSON object, enforcing the presence of required properties and ignoring the order of properties.

ReadObject(JsonReader, IEnumerable<String>, Action<JsonReader,String>)

Reads the properties of JSON objects, enforcing the presence of required properties and ignoring the order of properties.

ReadObject(JsonReader, IEnumerable<String>, IEnumerable<String>, Action<JsonReader,String>)

Reads the properties of JSON objects, enforcing the presence of required properties and ignoring the order of properties.

ReadObjectAndAdvance(JsonReader, IEnumerable<String>, Action<JsonReader,String>)

Reads the properties of JSON objects, enforcing the presence of required properties and ignoring the order of properties, and then advances the given reader to the next token after the end of the object.

Applies to