У меня есть следующий json:
Код: Выделить всё
{
"product_id": 1
}
Код: Выделить всё
public class FooDto
{
[JsonPropertyName("product_id")]
public long? ProductId { get; set; }
}
Код: Выделить всё
{
"product_id": 1
}
Код: Выделить всё
{
"productId": 1
}
Код: Выделить всё
JsonSerializer.Deserialize(json);
Код: Выделить всё
JsonSerializerOptions serializeOptions = new ()
{
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
WriteIndented = true
};
JsonSerializer.Deserialize(json, serializeOptions);
Подробнее здесь: https://stackoverflow.com/questions/790 ... -8-web-api
Мобильная версия