asp.net - How to parse data in a List from JSON data like following link using C#? -
how parse data in list json data following link using c# ?
{ "voters": [{ "id": "5644309456813", "name": "rimi khanom", "address": "house no: 12. road no: 14. dhanmondi, dhaka", "date_of_birth": "1979-01-15" }, { "id": "9509623450915", "name": "asif latif", "address": "house no: 98. road no: 14. katalgonj, chittagong", "date_of_birth": "1988-07-11" }, { "id": "1098789543218", "name": "rakib hasan", "address": "vill. shantinagar. thana: katalgonj, faridpur", "date_of_birth": "1982-04-12" }, { "id": "7865409458659", "name": "rumon sarker", "address": "kishorginj", "date_of_birth": "1970-12-02" }, { "id": "8909854343334", "name": "gaji salah uddin", "address": "chittagong", "date_of_birth": "1965-06-16" }] }
you getting array of objects json. need foreach
on voters. javascript objects mapped dictionary<string, object>
in c#. pseudo code
using system.web.script.serialization; using system.net; using (var client = new webclient()) { var url = "http://nerdcastlebd.com/web_service/voterdb/index.php/voters/all/format/json"; var jsonstring = client.downloadstring(url); var json = new javascriptserializer().deserialize<dynamic>(jsonstring); foreach (dictionary<string, object> voter in json["voters"]) { var id = voter["id"].tostring(); // pull name, address , date_of_birth here } }
Comments
Post a Comment