Tuesday, November 5, 2019

Converting Json Object into List in C#


Json Object Structure :

var readResult = "{\"data\":[{\"id\":1,\"fullname\":\"Todd\",\"email\":\"phoenix@apiexample.com\",\"age\":19,\"address\":\"No:49,anna salai\"}]}"


Conversion logic :

JObject jObject = JObject.Parse(readResult);
JArray user = (JArray)jObject["data"];
List<user> UserObj = user.ToObject<List<user>>();

The user model contains following properties

id, fullname, email, age, address

No comments:

Post a Comment