Deserialize in a list from JSON to VB.NET -
i work httprequest , receive response of group of array in json. want parse in vb.net in list access @ that:
list.index(0).messages.id list.index(0).messages.previous list.index(0).messages.last_update list.index(0).messages.html
thank help, hope understand problem
if getting json array, why not deserialize array only? , can use .tolist()
method convert array list
.
your classes should like:
public class message { public int id { get; set; } public int previous { get; set; } public int last_update { get; set; } public string html { get; set; } } public class rootobject { public string robots { get; set; } public list<message> messages { get; set; } public list<int> messageids { get; set; } public string onlineusers { get; set; } public string reverse { get; set; } public int lastrefresh { get; set; } public string motd { get; set; } public int numinchat { get; set; } public bool twelvehour { get; set; } public string _visitor_conversationsunread { get; set; } public string _visitor_alertsunread { get; set; } }
and should able deserialize full json rootobject
class directly. deserialize, suggest newtonsoft.json dll(available @ nuget)
rootobject rootobject = jsonconvert.deserializeobject<rootobject>(jsonstring);
then able access properties asked.
i took of http://json2csharp.com/ generate classes json
Comments
Post a Comment