Class OptionalConverters
- Namespace
- Nerdbank.Json
- Assembly
- Nerdbank.Json.dll
Opt-in converters for dynamic objects and document models.
public static class OptionalConverters
- Inheritance
-
OptionalConverters
- Inherited Members
Methods
WithDynamicObjectConverter(JsonSerializer)
Adds an object converter whose read-only dictionaries also support dynamic member access.
public static JsonSerializer WithDynamicObjectConverter(this JsonSerializer serializer)
Parameters
serializerJsonSerializerThe serializer to configure.
Returns
- JsonSerializer
A new serializer with the converter registered.
WithExpandoObjectConverter(JsonSerializer)
Adds a converter for ExpandoObject.
public static JsonSerializer WithExpandoObjectConverter(this JsonSerializer serializer)
Parameters
serializerJsonSerializerThe serializer to configure.
Returns
- JsonSerializer
A new serializer with the converter registered.
Remarks
Nested objects are read-only dictionaries supporting dynamic member access.
WithJsonValueConverter(JsonSerializer)
Adds converters for the native JsonValue hierarchy, preserving exact number tokens.
public static JsonSerializer WithJsonValueConverter(this JsonSerializer serializer)
Parameters
serializerJsonSerializerThe serializer to configure.
Returns
- JsonSerializer
A new serializer with the converters registered.
WithNameValueCollectionConverter(JsonSerializer)
Adds a converter for NameValueCollection.
public static JsonSerializer WithNameValueCollectionConverter(this JsonSerializer serializer)
Parameters
serializerJsonSerializerThe serializer to configure.
Returns
- JsonSerializer
A new serializer with the converter registered.
Remarks
Values are represented as null, a single string, or an array of strings. Null keys are not representable in a JSON object.
WithObjectConverter(JsonSerializer)
Adds a converter for values declared as object.
public static JsonSerializer WithObjectConverter(this JsonSerializer serializer)
Parameters
serializerJsonSerializerThe serializer to configure.
Returns
- JsonSerializer
A new serializer with the converter registered.
Remarks
Reads JSON into primitives, read-only dictionaries with string-valued object keys, and object arrays. Non-negative integers are read as ulong, negative integers as long, and fractional or exponent-form numbers as double. Other runtime types can be serialized only when their shape is available from the operation's provider. Use the native JsonValue model when exact number-token fidelity is required.
WithSystemTextJsonConverters(JsonSerializer)
Adds converters for System.Text.Json document, element, and node values.
public static JsonSerializer WithSystemTextJsonConverters(this JsonSerializer serializer)
Parameters
serializerJsonSerializerThe serializer to configure.
Returns
- JsonSerializer
A new serializer with the converters registered.
Exceptions
- ArgumentException
A converter for one of these types is already registered.