JSON сериализация C#

Есть такой вот код:

HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://api.commex.com/api/v1/ticker/bookTicker?symbol=SHIBUSDT");
client.DefaultRequestHeaders.Accept.Add(
   new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync(urlParameters).Result;
if (response.IsSuccessStatusCode)
{
    var dataObjects = response.Content.ReadAsStringAsync().Result;  
    DataObject.Symbols smb = new DataObject.Symbols();
    Datas = new List<DataObject.Symbols>();
    Datas.AddRange((IEnumerable<DataObject.Symbols>)JsonSerializer.Deserialize<DataObject.Symbols>(dataObjects));
    var res = Datas.FirstOrDefault(s => s.symbol.ToLower() == "shibusdt");
    if (res !=null)
    {
        Console.WriteLine($"Наименование Ордера: {res}");
    }
    Console.WriteLine(dataObjects);
}
else
{
    Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
}

// Make any other calls using HttpClient here.

// Dispose once all HttpClient calls are complete. This is not necessary if the containing object will be disposed of; for example in this case the HttpClient instance will be disposed automatically when the application terminates so the following call is superfluous.
client.Dispose();

Получается делаю запрос на Биржу, чтобы получить стоимость ордера.

Использую такой класс для данных:

public class DataObject
{
    public class Symbols
    {
        public string symbol { get; set; }
        public double bidPrice { get; set; }
        public double bidQty { get; set; }
        public double askPrice { get; set; }
        public double askQty { get; set; }
    }
}

JSON который мы должны получить из ответа, их очень много таких в 1 ответе:

{"symbol":"SHIBUSDT","bidPrice":"0.00001056","bidQty":"6063402.00","askPrice":"0.00001059","askQty":"6754419.00"}

А ошибку пишет такого типа:

System.Text.Json.JsonException: The JSON value could not be converted to APIS_TRADE+DataObject+Symbols. Path: $ | LineNumber: 0 | BytePositionInLine: 1.
   at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at APIS_TRADE.GET_INFO() in C:\Users\DarkFather\source\repos\Trade 0.1\Trade 0.1\Program.cs:line 54

Подскажите пожалуйста, битый час уже бьюсь не могу понять свою ошибку, где я упёрся в стену?


Ответы (0 шт):