я десериализую мою json строку в свойства класса
мой json
[
{
"Events": [
{
"DeviceId": "apc51"
}
]
}
]
мой код десериализации
TcpClient client = (TcpClient)obj;
var stream = client.GetStream();
string imei = String.Empty;
string recivedData = "";
Byte[] bytes = new Byte[256];
int i;
try
{
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
string hex = BitConverter.ToString(bytes);
recivedData = recivedData + Encoding.ASCII.GetString(bytes, 0, i);
}
//recivedData="[\r\n {\r\n \"Events\": [\r\n {\r\n \"DeviceId\":\"apc51\"\r\n }\r\n //]\r\n }\r\n]"
var result = JsonConvert.DeserializeObject<List<Events>>(recivedData);
значение результата Я получение
Count = 1 System.Collections.Generic.List<TCPSW.Events>
[0] {TCPSW.Events} TCPSW.Events
DeviceId null string
Я получаю значение DeviceId равно нулю
модальный класс равен
public class Events
{
[JsonProperty("DeviceId")]
public String DeviceId { get; set; }
}
что мне не хватает? это проблема в json?