Десериализация JSON : несколько объектов внутри
I have sample code ,that work fine. public class Employee { public int ID { get; set; } public string Name { get; set; } public string Address { get; set; } } private void JSONDeserilaize() { string json = @"{ 'ID': '1', 'Name': 'Manas', 'Address': 'India' }"; Employee empObj = JsonConvert.DeserializeObject<Employee>(json); Response.Write(empObj.Name); } But my json string is in this format. string json = @"{'ID': '1','Name': 'Manas','Address': 'India',"data":{"EmpDeptId":"20172807"}}"; How to fetch EmpDeptId along with Id,Name and Address.
Что я уже пробовал:
public class Employee { public int ID { get; set; } public string Name { get; set; } public string Address { get; set; } } private void JSONDeserilaize() { string json = @"{ 'ID': '1', 'Name': 'Manas', 'Address': 'India' }"; Employee empObj = JsonConvert.DeserializeObject<Employee>(json); Response.Write(empObj.Name); }