Class JsonSerializerOptionsConfiguration
- Namespace
- Cratis.Arc
- Assembly
- Cratis.Arc.Core.dll
Extension methods for configuring JsonSerializerOptions.
public static class JsonSerializerOptionsConfiguration
- Inheritance
-
JsonSerializerOptionsConfiguration
- Inherited Members
Methods
ConfigureArcDefaults(JsonSerializerOptions, IDerivedTypes?)
Configure the JsonSerializerOptions with Arc defaults.
public static JsonSerializerOptions ConfigureArcDefaults(this JsonSerializerOptions options, IDerivedTypes? derivedTypes = null)
Parameters
optionsJsonSerializerOptionsThe JsonSerializerOptions to configure.
derivedTypesIDerivedTypesOptional IDerivedTypes to use for derived type serialization.
Returns
- JsonSerializerOptions
The configured JsonSerializerOptions for continuation.
Remarks
Besides naming, number handling and converters, this sets up how the options resolve type metadata. Arc adds a single resolver to the end of TypeInfoResolverChain, after any resolver the options were already configured with, so the application's own contracts win. That resolver consults, in order:
-
Any resolver appended to the chain after this call, as
TypeInfoResolverChain.Add(...)made it the only resolver before Arc shipped source-generated metadata. - Arc's source-generated metadata for its own wire types, such as the command and query results.
- The reflection-based resolver, only when reflection-based serialization is enabled (IsReflectionEnabledByDefault). It is the resolver JsonSerializer falls back to for options that have none, so every type that serialized before still serializes the same way.
Add an application's source-generated JsonSerializerContext through AddJsonTypeInfoResolver(IJsonTypeInfoResolver), which places it ahead of Arc's resolver. Assigning TypeInfoResolver replaces the whole chain, Arc's resolver included.