C# helper class for parse Foursquare venue API in Windows Phone

I am developing a Windows Phone 8 app for and I need to get the list of Hospitals near Colombo, Sri Lanka and get the contact details of them. I used Foursquare Venue API from this url https://api.foursquare.com/v2/venues/search?client_id=[my_client_id]&client_secret=[my_client_secret]&v=20130815&ll=6.93,79.84&query=Hospital and the returned JSON was

{
"meta": {
"code": 200
},
"response": {
"venues": [
{
"id": "4eda2570e5fa78b16dcf7550",
"name": "Dutch Hospital",
"contact": {
"phone": "+94771988514",
"formattedPhone": "+94 77 198 8514"
},
"location": {
"address": "Hospital St.",
"crossStreet": "Bank of Ceylon Rd",
"lat": 6.932962882932079,
"lng": 79.84365501768762,
"distance": 521,
"postalCode": "00100",
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d1fd941735",
"name": "Mall",
"pluralName": "Malls",
"shortName": "Mall",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/shops/mall_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 4265,
"usersCount": 1799,
"tipCount": 32
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 4,
"groups": [
{
"type": "others",
"name": "Other people here",
"count": 4,
"items": []
}
]
},
"referralId": "v-1393002003"
},
{
"id": "4c51724f3940be9a0a78db08",
"name": "The Central Hospital",
"contact": {},
"location": {
"address": "Norris Canal Road",
"lat": 6.920411604865308,
"lng": 79.86604805238619,
"distance": 3070,
"cc": "LK",
"city": "Colombo 10",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 2214,
"usersCount": 919,
"tipCount": 48
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 1,
"groups": [
{
"type": "others",
"name": "Other people here",
"count": 1,
"items": []
}
]
},
"referralId": "v-1393002003"
},
{
"id": "4d535d21b3d9a35d6546c27b",
"name": "Nawaloka Hospital",
"contact": {
"phone": "011544444",
"formattedPhone": "011544444"
},
"location": {
"address": "H.K. Dharmadasa Mawatha",
"lat": 6.920275960794575,
"lng": 79.85380752271621,
"distance": 1870,
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 2692,
"usersCount": 1209,
"tipCount": 40
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4f1ffcd0e4b0a621106ad242",
"name": "Odel@ Dutch Hospital",
"contact": {},
"location": {
"lat": 6.933136700842684,
"lng": 79.84366048810165,
"distance": 534,
"cc": "LK",
"city": "Fort",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d127951735",
"name": "Arts & Crafts Store",
"pluralName": "Arts & Crafts Stores",
"shortName": "Arts & Crafts",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/shops/artstore_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 73,
"usersCount": 56,
"tipCount": 4
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "5124a839e4b089c766120376",
"name": "Avirate @ Dutch Hospital",
"contact": {},
"location": {
"lat": 6.933521464786437,
"lng": 79.8437917779364,
"distance": 573,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d108951735",
"name": "Women's Store",
"pluralName": "Women's Stores",
"shortName": "Women's Store",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/shops/apparel_women_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 6,
"usersCount": 6,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4bb17dd9f964a52093963ce3",
"name": "Durdans Hospital",
"contact": {},
"location": {
"lat": 6.902042373474421,
"lng": 79.85371453632025,
"distance": 3461,
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 2766,
"usersCount": 1144,
"tipCount": 36
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "51184f95e4b0e3bf0777ecc4",
"name": "Hospital Road",
"contact": {},
"location": {
"lat": 6.865770976231921,
"lng": 79.87347467655974,
"distance": 8050,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d1f9931735",
"name": "Road",
"pluralName": "Roads",
"shortName": "Road",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/travel/highway_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 306,
"usersCount": 6,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "505cae7ae4b033df3968919b",
"name": "Dutch hospital",
"contact": {},
"location": {
"lat": 6.909032665532989,
"lng": 79.86464797063267,
"distance": 3587,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d116941735",
"name": "Bar",
"pluralName": "Bars",
"shortName": "Bar",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/nightlife/bar_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 111,
"usersCount": 83,
"tipCount": 3
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "516e6970e4b0f76dd898b301",
"name": "Nawaloka Hospital Reporting Room",
"contact": {},
"location": {
"address": "H.K Daramadasa Maratha",
"lat": 6.917815228349451,
"lng": 79.8515539424727,
"distance": 1862,
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 7,
"usersCount": 7,
"tipCount": 1
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4c3dc584933b0f47b3d0e521",
"name": "Joseph Frazer Mem. Hospital",
"contact": {},
"location": {
"address": "Joseph Frazer Rd",
"lat": 6.895090184451606,
"lng": 79.86523316375843,
"distance": 4783,
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d104941735",
"name": "Medical Center",
"pluralName": "Medical Centers",
"shortName": "Medical",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 206,
"usersCount": 120,
"tipCount": 7
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 1,
"groups": [
{
"type": "others",
"name": "Other people here",
"count": 1,
"items": []
}
]
},
"referralId": "v-1393002003"
},
{
"id": "51d337af498e460c2cd890e0",
"name": "Capitol Hospital",
"contact": {},
"location": {
"lat": 6.913005,
"lng": 79.854571,
"distance": 2484,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 0,
"usersCount": 0,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4fc2f3f1e4b0e4e80d806e3b",
"name": "General Hospital",
"contact": {},
"location": {
"lat": 6.918850852346388,
"lng": 79.86687387142905,
"distance": 3218,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 156,
"usersCount": 99,
"tipCount": 8
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4e5f1d30c65bba7166a20f56",
"name": "General hospital",
"contact": {},
"location": {
"address": "Colombo North",
"lat": 6.913431866163409,
"lng": 79.85473191155839,
"distance": 2460,
"cc": "LK",
"city": "Ragama",
"country": "Sri Lanka"
},
"categories": [],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 6,
"usersCount": 5,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "50b436ac498ece0fc15f7dd7",
"name": "mental hospital",
"contact": {},
"location": {
"lat": 6.904201400029536,
"lng": 79.86109844496997,
"distance": 3699,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 10,
"usersCount": 9,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4faa15a4e4b03532c7a48413",
"name": "L W Hospital",
"contact": {},
"location": {
"address": "Kolpity",
"lat": 6.908304787706568,
"lng": 79.85259322206551,
"distance": 2787,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 2,
"usersCount": 2,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "52c632fe498ebb6eff043df1",
"name": "the central hospital toilet",
"contact": {},
"location": {
"lat": 6.91947078704834,
"lng": 79.86637115478516,
"distance": 3141,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 1,
"usersCount": 1,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "511a4cf2e4b06e75f599393c",
"name": "Central Hospital Billing Department",
"contact": {},
"location": {
"lat": 6.920695,
"lng": 79.865847,
"distance": 3038,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 10,
"usersCount": 8,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4f473d7fe4b0e44504676439",
"name": "Sulaimans Hospital",
"contact": {},
"location": {
"lat": 6.941850601094784,
"lng": 79.86565975069124,
"distance": 3127,
"postalCode": "01400",
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 51,
"usersCount": 36,
"tipCount": 2
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "52071eae498ea99bf74b115d",
"name": "hospital",
"contact": {},
"location": {
"lat": 6.835643291473389,
"lng": 79.98396301269531,
"distance": 19064,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 0,
"usersCount": 0,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4f128149e4b072565dd2c995",
"name": "Sunway Hospital",
"contact": {},
"location": {
"crossStreet": "Sri Gunananda Mawatha",
"lat": 6.951821527931256,
"lng": 79.86075934567175,
"distance": 3341,
"postalCode": "01300",
"cc": "LK",
"city": "Kotahena",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 10,
"usersCount": 3,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "52ef348411d21039a99acc3e",
"name": "Durdans Hospital Audiology Department",
"contact": {},
"location": {
"lat": 6.90208101272583,
"lng": 79.85363006591797,
"distance": 3453,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 2,
"usersCount": 2,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4bd986d55f50b7132c17e0d1",
"name": "Asiri Surgical Hospital Ltd.",
"contact": {},
"location": {
"address": "Kirimandala Mawatha, Narahenpita",
"lat": 6.894687186049523,
"lng": 79.87978935241699,
"distance": 5898,
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 1792,
"usersCount": 878,
"tipCount": 22
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "5258e99911d2435ca5580b22",
"name": "Durdans Hospital Second Floor",
"contact": {},
"location": {
"lat": 6.9026813459295635,
"lng": 79.85381299250115,
"distance": 3402,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 10,
"usersCount": 8,
"tipCount": 1
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "51e8e920498e599078233194",
"name": "Winsetha Hospital",
"contact": {},
"location": {
"lat": 6.91779850698253,
"lng": 79.87182315448152,
"distance": 3769,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 2,
"usersCount": 2,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4f20fca9e4b0272a5696fba7",
"name": "Durdans Hospital Pharmacy",
"contact": {},
"location": {
"address": "Colombo",
"lat": 6.901933510183676,
"lng": 79.85484677576763,
"distance": 3528,
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d10f951735",
"name": "Drugstore / Pharmacy",
"pluralName": "Drugstores / Pharmacies",
"shortName": "Pharmacy",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/shops/pharmacy_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 35,
"usersCount": 26,
"tipCount": 1
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4ca497f9f832a1cd174fa7e5",
"name": "Asiri Hospital",
"contact": {},
"location": {
"address": "Kirula road",
"lat": 6.89308983111156,
"lng": 79.87433870557145,
"distance": 5593,
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 1261,
"usersCount": 653,
"tipCount": 20
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "518b9cb0498e4a8bd0609479",
"name": "Hospital Junction",
"contact": {},
"location": {
"lat": 6.8425320492520365,
"lng": 79.92309883225059,
"distance": 13384,
"cc": "LK",
"country": "Sri Lanka"
},
"categories": [
{
"id": "50aa9e094b90af0d42d5de0d",
"name": "City",
"pluralName": "Cities",
"shortName": "City",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/parks_outdoors/neighborhood_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 6,
"usersCount": 5,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4f96405ee4b0dff9a0ce2873",
"name": "Borella Private Hospital",
"contact": {
"phone": "+94112692753",
"formattedPhone": "+94 11 2 692753"
},
"location": {
"address": "75",
"crossStreet": "Cotta Road",
"lat": 6.914139660802204,
"lng": 79.88037026682635,
"distance": 4797,
"cc": "LK",
"city": "Colombo 8",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d104941735",
"name": "Medical Center",
"pluralName": "Medical Centers",
"shortName": "Medical",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 91,
"usersCount": 8,
"tipCount": 0
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4c4add9342b4d13ab5a4d77d",
"name": "Park Hospital",
"contact": {},
"location": {
"address": "Park Road",
"lat": 6.887912942488723,
"lng": 79.87369537353516,
"distance": 5984,
"cc": "LK",
"city": "Colombo",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 122,
"usersCount": 78,
"tipCount": 1
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
},
{
"id": "4bb5c44ef562ef3b523c2f97",
"name": "Hemas Hospital",
"contact": {
"phone": "+94117888888",
"formattedPhone": "+94 11 7 888888"
},
"location": {
"address": "389, Negambo Road",
"lat": 6.988643157131234,
"lng": 79.89112973213196,
"distance": 8633,
"postalCode": "11300",
"cc": "LK",
"city": "Wattala",
"country": "Sri Lanka"
},
"categories": [
{
"id": "4bf58dd8d48988d196941735",
"name": "Hospital",
"pluralName": "Hospitals",
"shortName": "Hospital",
"icon": {
"prefix": "https://ss1.4sqi.net/img/categories_v2/building/medical_hospital_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"restricted": true,
"stats": {
"checkinsCount": 802,
"usersCount": 343,
"tipCount": 24
},
"specials": {
"count": 0,
"items": []
},
"hereNow": {
"count": 0,
"groups": []
},
"referralId": "v-1393002003"
}
]
}
}

Then I created a helper cs class to parse this, and the below is it.

public class Meta
{
    public int code { get; set; }
}

public class Contact
{
    public string phone { get; set; }
    public string formattedPhone { get; set; }
}

public class Location
{
    public string address { get; set; }
    public string crossStreet { get; set; }
    public double lat { get; set; }
    public double lng { get; set; }
    public int distance { get; set; }
    public string cc { get; set; }
    public string city { get; set; }
    public string country { get; set; }
    public string postalCode { get; set; }
}

public class Stats
{
    public int checkinsCount { get; set; }
    public int usersCount { get; set; }
    public int tipCount { get; set; }
}

public class Specials
{
    public int count { get; set; }
    public List<object> items { get; set; }
}

public class HereNow
{
    public int count { get; set; }
    public List<object> groups { get; set; }
}

public class Venue
{
    public string id { get; set; }
    public string name { get; set; }
    public Contact contact { get; set; }
    public Location location { get; set; }
    public List<object> categories { get; set; }
    public bool verified { get; set; }
    public bool restricted { get; set; }
    public Stats stats { get; set; }
    public Specials specials { get; set; }
    public HereNow hereNow { get; set; }
    public string referralId { get; set; }
}

public class Response
{
    public List<Venue> venues { get; set; }
}

public class RootObject
{
    public Meta meta { get; set; }
    public Response response { get; set; }
}

Using this class to parse JSON and Longlist selector, I managed to complete the project today.

App screenshot
App screenshot

This is the full code of MainPage.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using PhoneApp4.Resources;
using Newtonsoft.Json;
using System.Collections.ObjectModel;

namespace PhoneApp4
{
    public class HospitalDetails
    {
        private string _placeName;
        private string _contactNo;

        public string NameofHospital
        {
            get { return _placeName; }
            set { _placeName = value; }
        }

        public string ContactOfHospital
        {
            get { return _contactNo; }
            set { _contactNo = value; }
        }

        public HospitalDetails(string name, string phone)
        {
            this.NameofHospital = name;
            this.ContactOfHospital = phone;
        }
    }

    public partial class MainPage : PhoneApplicationPage
    {
        ObservableCollection<HospitalDetails> Restaurents = new ObservableCollection<HospitalDetails>();

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            PlacesList.ItemsSource = Restaurents;
        }

        private void btnCheck_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                WebClient wc = new WebClient();
                wc.DownloadStringCompleted += HttpCompleted;
                string uri = String.Format("https://api.foursquare.com/v2/venues/search?client_id=[my_client_id]&client_secret=[my_client_secret]&v=20130815&ll=6.93,79.84&query=Hospital");
                wc.DownloadStringAsync(new Uri(uri));
            }

            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }

        private void HttpCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                RootObject obj = JsonConvert.DeserializeObject<RootObject>(e.Result);
                foreach (var venue in obj.response.venues)
                {
                    Restaurents.Add(new HospitalDetails(venue.name, venue.contact.phone));
                }

            }

            catch (Exception httpErr)
            {
                MessageBox.Show(httpErr.Message);
            }
        }

        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);
        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
    }

    //********************JSON CLASS HERE***************************
    public class Meta
    {
        public int code { get; set; }
    }

    public class Contact
    {
        public string phone { get; set; }
        public string formattedPhone { get; set; }
    }

    public class Location
    {
        public string address { get; set; }
        public double lat { get; set; }
        public double lng { get; set; }
        public int distance { get; set; }
        public string postalCode { get; set; }
        public string cc { get; set; }
        public string city { get; set; }
        public string country { get; set; }
        public string crossStreet { get; set; }
    }

    public class Stats
    {
        public int checkinsCount { get; set; }
        public int usersCount { get; set; }
        public int tipCount { get; set; }
    }

    public class Specials
    {
        public int count { get; set; }
        public List<object> items { get; set; }
    }

    public class HereNow
    {
        public int count { get; set; }
        public List<object> groups { get; set; }
    }

    public class Venue
    {
        public string id { get; set; }
        public string name { get; set; }
        public Contact contact { get; set; }
        public Location location { get; set; }
        public List<object> categories { get; set; }
        public bool verified { get; set; }
        public bool restricted { get; set; }
        public Stats stats { get; set; }
        public Specials specials { get; set; }
        public HereNow hereNow { get; set; }
        public string referralId { get; set; }
    }

    public class Response
    {
        public List<Venue> venues { get; set; }
    }

    public class RootObject
    {
        public Meta meta { get; set; }
        public Response response { get; set; }
    }
}

This is the MainPage.xaml file

<phone:PhoneApplicationPage
    x:Class="PhoneApp4.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="768"/>
        </Grid.RowDefinitions>

        <!-- LOCALIZATION NOTE:
            To localize the displayed strings copy their values to appropriately named
            keys in the app's neutral language resource file (AppResources.resx) then
            replace the hard-coded text value between the attributes' quotation marks
            with the binding clause whose path points to that string name.

            For example:

                Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"

            This binding points to the template's string resource named "ApplicationTitle".

            Adding supported languages in the Project Properties tab will create a
            new resx file per language that can carry the translated values of your
            UI strings. The binding in these examples will cause the value of the
            attributes to be drawn from the .resx file that matches the
            CurrentUICulture of the app at run time.
         -->

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,751"/>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Margin="12,17,12,0">
            <!--phone:LongListSelector x:Name="PlacesList" HorizontalAlignment="Left" Height="667" VerticalAlignment="Top" Width="436" Margin="10,10,0,0"/-->
            <phone:LongListSelector Name="PlacesList" Margin="0">
                <phone:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="10" >
                            <TextBlock Text="{Binding NameofHospital}" FontSize="36"/>
                            <TextBlock Text="{Binding ContactOfHospital}"/>
                        </StackPanel>
                    </DataTemplate>
                </phone:LongListSelector.ItemTemplate>
            </phone:LongListSelector>
            <Button x:Name="btnCheck" Content="Check for places" HorizontalAlignment="Left" Margin="114,677,0,0" VerticalAlignment="Top" Click="btnCheck_Click"/>
        </Grid>

        <!--Uncomment to see an alignment grid to help ensure your controls are
            aligned on common boundaries.  The image has a top margin of -32px to
            account for the System Tray. Set this to 0 (or remove the margin altogether)
            if the System Tray is hidden.

            Before shipping remove this XAML and the image itself.-->
        <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
    </Grid>

</phone:PhoneApplicationPage>
Advertisements

2 thoughts on “C# helper class for parse Foursquare venue API in Windows Phone

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s