Method AddApiJson
AddApiJson(IServiceCollection, IJsonTypeInfoResolver, Action<JsonSerializerOptions>?)
Configures the JSON serializer options of minimal API requests and responses (JsonOptions) and of
SignalR hub payloads (PayloadSerializerOptions): inserts resolver at the front of their type
info resolvers, runs configure, then applies the API null handling (see ConfigureApiNullHandling(JsonSerializerOptions)).
Declaration
public static IServiceCollection AddApiJson(this IServiceCollection services, IJsonTypeInfoResolver resolver, Action<JsonSerializerOptions>? configure = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceCollection | services | The service collection. |
| IJsonTypeInfoResolver | resolver | The type info resolver of the app's API types, such as a source-generated JsonSerializerContext. |
| Action<JsonSerializerOptions> | configure | An optional callback that configures each of the two options instances before the null handling is applied. Resolvers it adds are covered by the null handling. |
Returns
| Type | Description |
|---|---|
| IServiceCollection |
Remarks
The hub payload options are configured whether SignalR is registered before or after this call, and are only used if it is registered. Configuration of either options instance that is registered after this call runs after it, so resolvers that it adds are not covered by the null handling.