Class JsonDeserializer
- Namespace
- Xunit.Sdk
- Assembly
- xunit.v3.common.dll
A special-purpose untyped deserializer for JSON. JSON strings are returned as string,
JSON numbers are returned as decimal, JSON booleans are returns as bool,
JSON objects are returned as IReadOnlyDictionary<string, object?>, JSON arrays are
returned as object?[], and JSON null values are returned as null. Static methods exist
here to help retrieve values from object dictionaries as well as convert to the commonly supported
data types (bool, DateTimeOffset, decimal, Enum,
int, long, string, and trait dictionaries (which are
decoded to IReadOnlyDictionary<string, IReadOnlyList<string>>), as well as arrays
of all the supported types (except trait dictionaries). Developers who need support for other types
are encouraged to encode and decode then as strings as needed (for examples, you can see how
Enum and DateTimeOffset values are handled here).
public static class JsonDeserializer
- Inheritance
-
JsonDeserializer
- Inherited Members
Remarks
These types are made public for third parties only for the purpose of serializing and deserializing messages that are sent across the process boundary (that is, types which implement IMessageSinkMessage). Any other usage is not supported.
Methods
- TryGetArray(IReadOnlyDictionary<string, object?>, string)
Tries to get an untyped array value from a deserialized JSON object.
- TryGetArray(object?)
Tries to get an untyped array value from a deserialized JSON value.
- TryGetArrayOfBoolean(IReadOnlyDictionary<string, object?>, string)
Tries to get an array of bool values from a deserialized JSON object. If the value isn't an array, or if any of the values in the array aren't compatible with bool, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfBoolean(object?)
Tries to get an array of bool values from a deserialized JSON value. If the value isn't an array, or if any of the values in the array aren't compatible with bool, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfDateTimeOffset(IReadOnlyDictionary<string, object?>, string)
Tries to get an array of DateTimeOffset values from a deserialized JSON object. If the value isn't an array, or if any of the values in the array aren't compatible with DateTimeOffset, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfDateTimeOffset(object?)
Tries to get an array of DateTimeOffset values from a deserialized JSON value. If the value isn't an array, or if any of the values in the array aren't compatible with DateTimeOffset, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfDecimal(IReadOnlyDictionary<string, object?>, string)
Tries to get an array of decimal values from a deserialized JSON object. If the value isn't an array, or if any of the values in the array aren't compatible with decimal, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfDecimal(object?)
Tries to get an array of decimal values from a deserialized JSON value. If the value isn't an array, or if any of the values in the array aren't compatible with decimal, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfEnum<TEnum>(IReadOnlyDictionary<string, object?>, string)
Tries to get an array of
TEnumvalues from a deserialized JSON object. If the value isn't an array, or if any of the values in the array aren't compatible withTEnum, then returnsnull. Null values in the array are not permitted.
- TryGetArrayOfEnum<TEnum>(object?)
Tries to get an array of
TEnumvalues from a deserialized JSON value. If the value isn't an array, or if any of the values in the array aren't compatible withTEnum, then returnsnull. Null values in the array are not permitted.
- TryGetArrayOfInt(IReadOnlyDictionary<string, object?>, string)
Tries to get an array of int values from a deserialized JSON object. If the value isn't an array, or if any of the values in the array aren't compatible with int, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfInt(object?)
Tries to get an array of int values from a deserialized JSON value. If the value isn't an array, or if any of the values in the array aren't compatible with int, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfLong(IReadOnlyDictionary<string, object?>, string)
Tries to get an array of long values from a deserialized JSON object. If the value isn't an array, or if any of the values in the array aren't compatible with long, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfLong(object?)
Tries to get an array of long values from a deserialized JSON value. If the value isn't an array, or if any of the values in the array aren't compatible with long, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfNullableString(IReadOnlyDictionary<string, object?>, string)
Tries to get an array of string values from a deserialized JSON object. If the value isn't an array, or if any of the values in the array aren't compatible with string, then returns
null. Null values in the array are permitted.
- TryGetArrayOfNullableString(object?)
Tries to get an array of string values from a deserialized JSON value. If the value isn't an array, or if any of the values in the array aren't compatible with string, then returns
null. Null values in the array are permitted.
- TryGetArrayOfString(IReadOnlyDictionary<string, object?>, string)
Tries to get an array of string values from a deserialized JSON object. If the value isn't an array, or if any of the values in the array aren't compatible with string, then returns
null. Null values in the array are not permitted.
- TryGetArrayOfString(object?)
Tries to get an array of string values from a deserialized JSON value. If the value isn't an array, or if any of the values in the array aren't compatible with string, then returns
null. Null values in the array are not permitted.
- TryGetBoolean(IReadOnlyDictionary<string, object?>, string)
Tries to get a bool value from a deserialized JSON object.
- TryGetBoolean(object?)
Tries to get a bool value from a deserialized JSON value.
- TryGetDateTimeOffset(IReadOnlyDictionary<string, object?>, string)
Tries to get a DateTimeOffset value from a deserialized JSON object.
- TryGetDateTimeOffset(object?)
Tries to get a DateTimeOffset value from a deserialized JSON value.
- TryGetDecimal(IReadOnlyDictionary<string, object?>, string)
Tries to get a decimal value from a deserialized JSON object.
- TryGetDecimal(object?)
Tries to get a decimal value from a deserialized JSON value.
- TryGetEnum<TEnum>(IReadOnlyDictionary<string, object?>, string)
Tries to get an Enum value from a deserialized JSON object.
- TryGetEnum<TEnum>(object?)
Tries to get an Enum value from a deserialized JSON value.
- TryGetInt(IReadOnlyDictionary<string, object?>, string)
Tries to get an int value from a deserialized JSON object.
- TryGetInt(object?)
Tries to get an int value from a deserialized JSON value.
- TryGetLong(IReadOnlyDictionary<string, object?>, string)
Tries to get a long value from a deserialized JSON object.
- TryGetLong(object?)
Tries to get an long value from a deserialized JSON value.
- TryGetObject(IReadOnlyDictionary<string, object?>, string)
Tries to get an untyped object value from a deserialized JSON object.
- TryGetObject(object?)
Tries to get an untyped object value from a deserialized JSON value.
- TryGetString(IReadOnlyDictionary<string, object?>, string, bool)
Tries to get a string value from a deserialized JSON object.
- TryGetString(object?, bool)
Tries to get an long value from a deserialized JSON value.
- TryGetTraits(IReadOnlyDictionary<string, object?>, string, bool)
Tries to get a trait dictionary value from a deserialized JSON object.
- TryGetTraits(object?)
Tries to get a string value from a deserialized JSON value.