asp.net - JSON Deserialization : Multiple object inside -
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 json string in format.
string json = @"{"id": "1","name": "manas","address": "india","data":{"empdeptid":"20172807"}}";
how fetch empdeptid along id,name , address.
declare class object deserialize into, add member of original class:
public class employee { public int id { get; set; } public string name { get; set; } public string address { get; set; } public employeedata data { get; set; } } public class employeedata { public string empdeptid {get; set; } }
it should deserialize data
accordingly.
Comments
Post a Comment