I have no idea about how to handle json, but I want to convert state_wise
json object into json array in c#. I want to loop through the state_wise
Json:
{
"key_values": null,
"total_values": {
"active": "2543914",
"confirmed": "16602456",
"deaths": "189549",
"deltaconfirmed": "344949",
"deltadeaths": "2620",
"deltarecovered": "220382",
"lastupdatedtime": "24/4/2021 00:09:14",
"migratedother": "6874",
"recovered": "13862119",
"state": "Total",
"statecode": "TT",
"statenotes": ""
},
"state_wise": {
"Maharashtra": {
"active": "691851",
"confirmed": "4161676",
"deaths": "63252",
"deltaconfirmed": "66836",
"deltadeaths": "773",
"deltarecovered": "74045",
"lastupdatedtime": "23/04/2021 21:15:15",
"migratedother": "1781",
"recovered": "3404792",
"state": "Maharashtra",
"statecode": "MH",
"statenotes": "[Dec 16]:10,218 duplicate cases & other state cases removed from total cases.791 recovered cases also removed from total recovered cases while reconciling \n[Sep 9] :239 cases have been removed from the hospitalized figures owing to the removal of duplicates and change of addresses as per the original residence\n[Aug 15] : MH bulletin has reduced 819 confirmed cases in Mumbai and 72 confirmed cases from 'Other States' from the tally\n[Jun 16] : 1328 deceased cases have been retroactively added to MH bulletin.\n[Jun 20] : 69 deceased cases have been reduced based on state bulletin."
},
"Kerala": {
"active": "178979",
"confirmed": "1350502",
"deaths": "5056",
"deltaconfirmed": "28447",
"deltadeaths": "27",
"deltarecovered": "5663",
"lastupdatedtime": "23/04/2021 19:32:13",
"migratedother": "332",
"recovered": "1166135",
"state": "Kerala",
"statecode": "KL",
"statenotes": "Mahe native who expired in Kannur included in Kerala's deceased tally.\nSome non-covid deaths have also been reported in the bulletin.\nThese have been reduced from active count"
}
}
}
first create a class with the property that you want to map. then parse json to the class at last you can use the class and it's property like this:
class for mapping to it:
public class version
{
public string version_Number { set; get; }
}
how to map:
string uri = "http://127.0.0.1:5000/api/version";
HttpClient client = new HttpClient();
string response = await client.GetStringAsync(uri);
System.Console.WriteLine(response);
var data = JsonConvert.DeserializeObject<version>(response);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.