我正在尝试将字符串中的数据写入对象。它不起作用,写道该行无效,但事实并非如此。
字符串(为方便起见格式化):
[
{
"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.
我的对象:
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; }
}
在我看来,这不是
int: