Для недавних проверок это довольно просто:
Dim UserSelfCheckins As FourSquare.UserSelfCheckins.Root
Dim ser As New JavaScriptSerializer()
UserSelfCheckins = ser.Deserialize(Of FourSquare.UserSelfCheckins.Root)(jsonstring)
С такими вспомогательными классами:
Namespace UserSelfCheckins
Public Class Root
Public Property meta As MetaProperties
Public Property response As ResponseProperties
End Class
Public Class MetaProperties
Public Property code As String
End Class
Public Class ResponseProperties
Public Property checkins As UserSelfCheckins
End Class
Public Class UserSelfCheckins
Public Property count As Integer
Public Property items As List(Of UserSelfCheckinProperties)
End Class
Public Class UserSelfCheckinProperties
Public Property createdAt As Long
Public Property venue As VenueProperties
End Class
Public Class VenueProperties
Public Property id As String
Public Property name As String
Public Property location As LocationProperty
Public Property categories As List(Of CategoriesProperty)
End Class
Public Class LocationProperty
Public Property city As String
Public Property state As String
End Class
End Namespace
Вы можете отобразить их с помощью этого:
@For Each item In UserSelfCheckins.response.checkins.items
@<li>
@item.venue.name
@item.venue.location.city
@item.venue.location.state
</li>
Next
Чего я не могу понять, так это того, как это сделать для списка значков, поскольку структура не постоянна. Это Response>Badges>[badgeID]>BadgeName. Поскольку BadgeID отличается для каждого из них, у меня возникают проблемы с написанием соответствующих классов.
После этого мне нужно найти разумный способ показать значки, которые фактически разблокированы.
Вот фрагмент JSON из двух значков — один разблокирован.
{
"meta": {
"code": 200
},
"response": {
"badges": {
"4cd0d5e2137c76b04864e9c5": {
"id": "4cd0d5e2137c76b04864e9c5",
"badgeId": "4c4f08667a0803bb02212ab7",
"name": "Groupie",
"description": "The Backstreet Boys of tech! The Menudo of the interne.... OMG! @NAVEEN JUST TOUCHED MY SHIRT!\n\n",
"image": {
"prefix": "https:\/\/plaayfoursquare.s3.amazonaws.com\/badge\/",
"sizes": [
57,
114,
200,
300,
400
],
"name": "\/sxsw2010_groupie.png"
},
"unlocks": [
{
"checkins": [
]
}
]
},
"4cb271c2c5e6a1cd61d2e5f6": {
"id": "4cb271c2c5e6a1cd61d2e5f6",
"badgeId": "4c4f08667a0803bb17212ab7",
"name": "Barista",
"description": "Congrats - you've checked in at 5 different Starbucks! Be sure to pick up a double tall latte for your friend - I'm sure they'd do the same for you.",
"image": {
"prefix": "https:\/\/playfoursquare.s3.amazonaws.com\/badge\/",
"sizes": [
57,
114,
200,
300,
400
],
"name": "\/barista.png"
},
"unlocks": [
{
"checkins": [
{
"id": "4cb271c1c5e6a1cd5ed2e5f6",
"createdAt": 1286762945,
"type": "checkin",
"timeZone": "America\/Los_Angeles",
"venue": {
"id": "4b4aa5c0f964a520318c26e3",
"name": "Starbucks",
"contact": {
"twitter": "starbucks"
},
"location": {
"address": "B Gates, Terminal 1",
"crossStreet": "LAS Airport",
"lat": 36.083164640690136,
"lng": -115.1517391204834,
"postalCode": "89119",
"city": "Las Vegas",
"state": "NV",
"country": "United States"
},
"categories": [
{
"id": "4bf58dd8d48988d1e0931735",
"name": "Coffee Shop",
"pluralName": "Coffee Shops",
"shortName": "Coffee Shop",
"icon": {
"prefix": "https:\/\/foursquare.com\/img\/categories\/food\/coffeeshop_",
"sizes": [
32,
44,
64,
88,
256
],
"name": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 1401,
"usersCount": 1282,
"tipCount": 13
}
},
"photos": {
"count": 0,
"items": [
]
},
"comments": {
"count": 0,
"items": [
]
}
}
]
}
]
}
},
"defaultSetType": "foursquare"
}
}