Код: Выделить всё
{
"name": "Peter",
"residence": {
"country": null,
"status": null
},
}
Код: Выделить всё
public record CreatePersonRequest(
string name,
Residence? residence
);
public record Residence(
string Country,
string Status
);
Код: Выделить всё
Country
В этом сценарии я хочу, чтобы десериализация JSON возвращала объект CreatePersonRequest со свойством Residence. как null.
Я попробовал установить JsonIgnoreCondition.WhenWritingNull, но это не сработало.
Код: Выделить всё
services.Configure(options =>
{
options.SerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});
Подробнее здесь: https://stackoverflow.com/questions/781 ... properties