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