JsonConvert.DeserializeObject | Не валидная строка?
Пытаюсь вписать данные из строки в объект. Не получается, пишет что строка не валидная, но это не так.
Строка(форматировал для удобства):
[
{
"timestamp": "2020-02-24T22:34:05.080Z",
"name": "SomeName",
"side": "red",
"number": 4,
"number2": 123.5,
"tickDirection": "MinusTick",
"trdMatchID": "f221055f-fef1-24cb-b21c-5dc717e6bc87",
"grossValue": 20686,
"homeNotional": 0.00020686,
"foreignNotional": 2
}
]
Вот так я пытаюсь распарсить её в объект:
JsonConvert.DeserializeObject<Myobjs.obj>(stroka);
Ошибка :
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type
'Myobjs.obj' because the type requires a JSON object (e.g. {"name":"value"})
to deserialize correctly.
Myobj:
public class LastTrade
{
public DateTime timestamp { get; set; }
public string name { get; set; }
public string side { get; set; }
public int number { get; set; }
public int number2 { get; set; }
public string tickDirection { get; set; }
public string trdMatchID { get; set; }
public int grossValue { get; set; }
public int homeNotional { get; set; }
public int foreignNotional { get; set; }
}
Ответы (1 шт):
Автор решения: Igor
→ Ссылка
JsonConvert.DeserializeObject<List<LastTrade>>(stroka);
По-моему, это не int-ы:
"number2": 123.5,
...
"homeNotional": 0.00020686,