For recent checkins it is pretty straightforward:
Dim UserSelfCheckins As FourSquare.UserSelfCheckins.Root
Dim ser As New JavaScriptSerializer()
UserSelfCheckins = ser.Deserialize(Of FourSquare.UserSelfCheckins.Root)(jsonstring)
With backing classes like this:
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
You can display them with this:
@For Each item In UserSelfCheckins.response.checkins.items
@<li>
@item.venue.name
@item.venue.location.city
@item.venue.location.state
</li>
Next
What I can’t figure out is how to do this for the list of badges as the structure isn’t constant. It is Response>Badges>[badgeID]>BadgeName. Since the BadgeID is different for each one I am having trouble writing matching classes.
After that figuring i’ll need to figure out a reasonable way to show badges that are actually unlocked.
Here is a snippet of the JSON from 2 badges – one unlocked.
{
"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"
}
}
I think I figured it out. What I was missing was turning the badges level into dictionary of string and object.
I needed this model:
And this: