Currently working on a program in vb.net that uses JSON.Net to read the destiny JSON files.
This is the JSON file.
{
"Response" : {
"data" : {
"membershipId" : "4611686018444289561",
"membershipType" : 2,
"characters" : [{
"characterBase" : {
"membershipId" : "4611686018444289561",
"membershipType" : 2,
"characterId" : "2305843009266226944",
"dateLastPlayed" : "2015-06-22T21:43:06Z",
"minutesPlayedThisSession" : "0",
"minutesPlayedTotal" : "17109",
"powerLevel" : 34,
"raceHash" : 2803282938,
"genderHash" : 2204441813,
"classHash" : 671679327,
"currentActivityHash" : 0,
"lastCompletedStoryHash" : 0,
"stats" : {
"STAT_DEFENSE" : {
"statHash" : 3897883278,
"value" : 1786,
"maximumValue" : 0
},
"STAT_INTELLECT" : {
"statHash" : 144602215,
"value" : 147,
"maximumValue" : 0
},
"STAT_DISCIPLINE" : {
"statHash" : 1735777505,
"value" : 266,
"maximumValue" : 0
},
"STAT_STRENGTH" : {
"statHash" : 4244567218,
"value" : 144,
"maximumValue" : 0
},
"STAT_LIGHT" : {
"statHash" : 2391494160,
"value" : 168,
"maximumValue" : 0
},
"STAT_ARMOR" : {
"statHash" : 392767087,
"value" : 8,
"maximumValue" : 0
},
"STAT_AGILITY" : {
"statHash" : 2996146975,
"value" : 5,
"maximumValue" : 0
},
"STAT_RECOVERY" : {
"statHash" : 1943323491,
"value" : 4,
"maximumValue" : 0
},
"STAT_OPTICS" : {
"statHash" : 3555269338,
"value" : 55,
"maximumValue" : 0
}
},
"customization" : {
"personality" : 2166136261,
"face" : 2695914755,
"skinColor" : 1815484265,
"lipColor" : 2844894632,
"eyeColor" : 1511637744,
"hairColor" : 1222512333,
"featureColor" : 2166136261,
"decalColor" : 2133206350,
"wearHelmet" : false,
"hairIndex" : 1,
"featureIndex" : 0,
"decalIndex" : 7
},
"grimoireScore" : 2680,
"peerView" : {
"equipment" : [{
"itemHash" : 1716862031,
"dyes" : []
}, {
"itemHash" : 144553854,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 3354041935
}, {
"channelHash" : 1367384683,
"dyeHash" : 3419191362
}, {
"channelHash" : 218592586,
"dyeHash" : 3389671913
}
]
}, {
"itemHash" : 3387472392,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 3354041935
}, {
"channelHash" : 1367384683,
"dyeHash" : 3419191362
}, {
"channelHash" : 218592586,
"dyeHash" : 3389671913
}
]
}, {
"itemHash" : 1496660238,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 3354041935
}, {
"channelHash" : 1367384683,
"dyeHash" : 3419191362
}, {
"channelHash" : 218592586,
"dyeHash" : 3389671913
}
]
}, {
"itemHash" : 3637940699,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 3354041935
}, {
"channelHash" : 1367384683,
"dyeHash" : 3419191362
}, {
"channelHash" : 218592586,
"dyeHash" : 3389671913
}
]
}, {
"itemHash" : 2282906673,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 1096181162
}, {
"channelHash" : 1367384683,
"dyeHash" : 1652075411
}, {
"channelHash" : 218592586,
"dyeHash" : 2703491298
}
]
}, {
"itemHash" : 3164616405,
"dyes" : [{
"channelHash" : 1667433279,
"dyeHash" : 3925656441
}, {
"channelHash" : 1667433278,
"dyeHash" : 3223521410
}
]
}, {
"itemHash" : 3327140886,
"dyes" : [{
"channelHash" : 1667433279,
"dyeHash" : 421485277
}, {
"channelHash" : 1667433278,
"dyeHash" : 2764135478
}
]
}, {
"itemHash" : 3153232297,
"dyes" : [{
"channelHash" : 1667433279,
"dyeHash" : 3805233741
}, {
"channelHash" : 1667433278,
"dyeHash" : 2741135462
}
]
}, {
"itemHash" : 1388583990,
"dyes" : [{
"channelHash" : 284967655,
"dyeHash" : 2328943074
}, {
"channelHash" : 840921382,
"dyeHash" : 162237873
}
]
}, {
"itemHash" : 3703598457,
"dyes" : [{
"channelHash" : 2025709351,
"dyeHash" : 794303093
}
]
}, {
"itemHash" : 2751204699,
"dyes" : [{
"channelHash" : 4023194814,
"dyeHash" : 1177926279
}
]
}, {
"itemHash" : 1825970520,
"dyes" : []
}, {
"itemHash" : 1947545036,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 3354041935
}, {
"channelHash" : 1367384683,
"dyeHash" : 3419191362
}, {
"channelHash" : 218592586,
"dyeHash" : 3389671913
}
]
}
]
},
"genderType" : 1,
"classType" : 1,
"buildStatGroupHash" : 633635316
},
"levelProgression" : {
"dailyProgress" : 0,
"weeklyProgress" : 10925,
"currentProgress" : 3769138,
"level" : 47,
"step" : 0,
"progressToNextLevel" : 9138,
"nextLevelAt" : 80000,
"progressionHash" : 2030054750
},
"emblemPath" : "/common/destiny_content/icons/71891e9447353b5adf45a55e1d5e0fee.jpg",
"backgroundPath" : "/common/destiny_content/icons/d482a38c8062563aa3bc641856b85161.jpg",
"emblemHash" : 1825970520,
"characterLevel" : 34,
"baseCharacterLevel" : 20,
"isPrestigeLevel" : true,
"percentToNextLevel" : 0.0
}, {
"characterBase" : {
"membershipId" : "4611686018444289561",
"membershipType" : 2,
"characterId" : "2305843009270904041",
"dateLastPlayed" : "2015-06-12T04:41:28Z",
"minutesPlayedThisSession" : "0",
"minutesPlayedTotal" : "1998",
"powerLevel" : 30,
"raceHash" : 3887404748,
"genderHash" : 2204441813,
"classHash" : 2271682572,
"currentActivityHash" : 0,
"lastCompletedStoryHash" : 0,
"stats" : {
"STAT_DEFENSE" : {
"statHash" : 3897883278,
"value" : 1509,
"maximumValue" : 0
},
"STAT_INTELLECT" : {
"statHash" : 144602215,
"value" : 130,
"maximumValue" : 0
},
"STAT_DISCIPLINE" : {
"statHash" : 1735777505,
"value" : 182,
"maximumValue" : 0
},
"STAT_STRENGTH" : {
"statHash" : 4244567218,
"value" : 177,
"maximumValue" : 0
},
"STAT_LIGHT" : {
"statHash" : 2391494160,
"value" : 126,
"maximumValue" : 0
},
"STAT_ARMOR" : {
"statHash" : 392767087,
"value" : 9,
"maximumValue" : 0
},
"STAT_AGILITY" : {
"statHash" : 2996146975,
"value" : 5,
"maximumValue" : 0
},
"STAT_RECOVERY" : {
"statHash" : 1943323491,
"value" : 7,
"maximumValue" : 0
},
"STAT_OPTICS" : {
"statHash" : 3555269338,
"value" : 49,
"maximumValue" : 0
}
},
"customization" : {
"personality" : 2166136261,
"face" : 2132087823,
"skinColor" : 3045033367,
"lipColor" : 404671481,
"eyeColor" : 1194006502,
"hairColor" : 2739213077,
"featureColor" : 2166136261,
"decalColor" : 2714701677,
"wearHelmet" : false,
"hairIndex" : 11,
"featureIndex" : 0,
"decalIndex" : 6
},
"grimoireScore" : 2680,
"peerView" : {
"equipment" : [{
"itemHash" : 3828867689,
"dyes" : []
}, {
"itemHash" : 813361818,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 2431473053
}, {
"channelHash" : 1367384683,
"dyeHash" : 2332768436
}, {
"channelHash" : 218592586,
"dyeHash" : 1281112403
}
]
}, {
"itemHash" : 1050422086,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 2775740718
}, {
"channelHash" : 1367384683,
"dyeHash" : 3142008767
}, {
"channelHash" : 218592586,
"dyeHash" : 291630158
}
]
}, {
"itemHash" : 3411635687,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 2775740718
}, {
"channelHash" : 1367384683,
"dyeHash" : 3142008767
}, {
"channelHash" : 218592586,
"dyeHash" : 291630158
}
]
}, {
"itemHash" : 2797907388,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 2775740718
}, {
"channelHash" : 1367384683,
"dyeHash" : 3142008767
}, {
"channelHash" : 218592586,
"dyeHash" : 291630158
}
]
}, {
"itemHash" : 2675543791,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 1537857451
}, {
"channelHash" : 1367384683,
"dyeHash" : 1501873614
}, {
"channelHash" : 218592586,
"dyeHash" : 504218347
}
]
}, {
"itemHash" : 3667595457,
"dyes" : [{
"channelHash" : 1667433279,
"dyeHash" : 401101184
}, {
"channelHash" : 1667433278,
"dyeHash" : 3599482519
}
]
}, {
"itemHash" : 1325979471,
"dyes" : [{
"channelHash" : 1667433279,
"dyeHash" : 716482169
}, {
"channelHash" : 1667433278,
"dyeHash" : 14347138
}
]
}, {
"itemHash" : 1274330686,
"dyes" : [{
"channelHash" : 1667433279,
"dyeHash" : 2289053638
}, {
"channelHash" : 1667433278,
"dyeHash" : 567827245
}
]
}, {
"itemHash" : 671526061,
"dyes" : [{
"channelHash" : 284967655,
"dyeHash" : 1437417001
}, {
"channelHash" : 840921382,
"dyeHash" : 2751843408
}
]
}, {
"itemHash" : 3703598457,
"dyes" : [{
"channelHash" : 2025709351,
"dyeHash" : 794303093
}
]
}, {
"itemHash" : 2751204699,
"dyes" : [{
"channelHash" : 4023194814,
"dyeHash" : 1177926279
}
]
}, {
"itemHash" : 1825970523,
"dyes" : []
}, {
"itemHash" : 1947545037,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 2775740718
}, {
"channelHash" : 1367384683,
"dyeHash" : 3142008767
}, {
"channelHash" : 218592586,
"dyeHash" : 291630158
}
]
}
]
},
"genderType" : 1,
"classType" : 2,
"buildStatGroupHash" : 2172613790
},
"levelProgression" : {
"dailyProgress" : 0,
"weeklyProgress" : 0,
"currentProgress" : 315183,
"level" : 3,
"step" : 0,
"progressToNextLevel" : 75183,
"nextLevelAt" : 80000,
"progressionHash" : 2030054750
},
"emblemPath" : "/common/destiny_content/icons/d6e630844fce9b8f875b9945a9d3ca5b.jpg",
"backgroundPath" : "/common/destiny_content/icons/6c4a10751aef0067be54dc2461711ea4.jpg",
"emblemHash" : 1825970523,
"characterLevel" : 30,
"baseCharacterLevel" : 20,
"isPrestigeLevel" : true,
"percentToNextLevel" : 50.0
}, {
"characterBase" : {
"membershipId" : "4611686018444289561",
"membershipType" : 2,
"characterId" : "2305843009306714231",
"dateLastPlayed" : "2015-06-12T04:40:44Z",
"minutesPlayedThisSession" : "31",
"minutesPlayedTotal" : "369",
"powerLevel" : 1,
"raceHash" : 898834093,
"genderHash" : 2204441813,
"classHash" : 3655393761,
"currentActivityHash" : 0,
"lastCompletedStoryHash" : 0,
"stats" : {
"STAT_DEFENSE" : {
"statHash" : 3897883278,
"value" : 214,
"maximumValue" : 0
},
"STAT_INTELLECT" : {
"statHash" : 144602215,
"value" : 0,
"maximumValue" : 0
},
"STAT_DISCIPLINE" : {
"statHash" : 1735777505,
"value" : 0,
"maximumValue" : 0
},
"STAT_STRENGTH" : {
"statHash" : 4244567218,
"value" : 78,
"maximumValue" : 0
},
"STAT_ARMOR" : {
"statHash" : 392767087,
"value" : 5,
"maximumValue" : 0
},
"STAT_AGILITY" : {
"statHash" : 2996146975,
"value" : 1,
"maximumValue" : 0
},
"STAT_RECOVERY" : {
"statHash" : 1943323491,
"value" : 1,
"maximumValue" : 0
},
"STAT_OPTICS" : {
"statHash" : 3555269338,
"value" : 49,
"maximumValue" : 0
}
},
"customization" : {
"personality" : 2166136261,
"face" : 2552882596,
"skinColor" : 4232663426,
"lipColor" : 1955118883,
"eyeColor" : 4187018147,
"hairColor" : 2324992807,
"featureColor" : 2166136261,
"decalColor" : 424152543,
"wearHelmet" : false,
"hairIndex" : 10,
"featureIndex" : 0,
"decalIndex" : 3
},
"grimoireScore" : 2680,
"peerView" : {
"equipment" : [{
"itemHash" : 2007186000,
"dyes" : []
}, {
"itemHash" : 706892687,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 747964525
}, {
"channelHash" : 1367384683,
"dyeHash" : 3147373164
}, {
"channelHash" : 218592586,
"dyeHash" : 1346091505
}
]
}, {
"itemHash" : 4042984494,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 215207960
}, {
"channelHash" : 1367384683,
"dyeHash" : 2280395877
}, {
"channelHash" : 218592586,
"dyeHash" : 768586838
}
]
}, {
"itemHash" : 1742813176,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 1250341018
}, {
"channelHash" : 1367384683,
"dyeHash" : 3468588859
}, {
"channelHash" : 218592586,
"dyeHash" : 4089917164
}
]
}, {
"itemHash" : 924874407,
"dyes" : [{
"channelHash" : 662199250,
"dyeHash" : 1431052853
}, {
"channelHash" : 1367384683,
"dyeHash" : 205143812
}, {
"channelHash" : 218592586,
"dyeHash" : 1119419865
}
]
}, {
"itemHash" : 1599594923,
"dyes" : []
}, {
"itemHash" : 1284289562,
"dyes" : [{
"channelHash" : 1667433279,
"dyeHash" : 129049218
}, {
"channelHash" : 1667433278,
"dyeHash" : 831184249
}
]
}, {
"itemHash" : 811663330,
"dyes" : [{
"channelHash" : 1667433279,
"dyeHash" : 2346743114
}, {
"channelHash" : 1667433278,
"dyeHash" : 4028939073
}
]
}, {
"itemHash" : 3167958228,
"dyes" : [{
"channelHash" : 1667433279,
"dyeHash" : 3449915848
}, {
"channelHash" : 1667433278,
"dyeHash" : 3907340927
}
]
}, {
"itemHash" : 1388583991,
"dyes" : [{
"channelHash" : 284967655,
"dyeHash" : 1571237171
}, {
"channelHash" : 840921382,
"dyeHash" : 4188234966
}
]
}, {
"itemHash" : 3703598457,
"dyes" : [{
"channelHash" : 2025709351,
"dyeHash" : 794303093
}
]
}, {
"itemHash" : 2751204699,
"dyes" : [{
"channelHash" : 4023194814,
"dyeHash" : 1177926279
}
]
}, {
"itemHash" : 1443409303,
"dyes" : []
}, {
"itemHash" : 4248210736,
"dyes" : []
}
]
},
"genderType" : 1,
"classType" : 0,
"buildStatGroupHash" : 3801959103
},
"levelProgression" : {
"dailyProgress" : 8395,
"weeklyProgress" : 8395,
"currentProgress" : 69375,
"level" : 10,
"step" : 0,
"progressToNextLevel" : 6875,
"nextLevelAt" : 13000,
"progressionHash" : 1716568313
},
"emblemPath" : "/common/destiny_content/icons/ee9d2fe8b039751ad3d9e48c7f476dc2.jpg",
"backgroundPath" : "/common/destiny_content/icons/e99ee1ccf976e482c274a2782283cd7d.jpg",
"emblemHash" : 1443409303,
"characterLevel" : 10,
"baseCharacterLevel" : 10,
"isPrestigeLevel" : false,
"percentToNextLevel" : 52.8846169
}
],
"inventory" : {
"buckets" : {
"Invisible" : [],
"Item" : [],
"Currency" : []
},
"currencies" : [{
"itemHash" : 3159615086,
"value" : 7022
}
]
},
"grimoireScore" : 2680,
"versions" : 7
}
},
"ErrorCode" : 1,
"ThrottleSeconds" : 0,
"ErrorStatus" : "Success",
"Message" : "Ok",
"MessageData" : {}
}
Im trying to pull all the data for each character and display it on the form in different ways but for now i would be happy to show the information in a message box just to make sure it is working.
This is my current code, there was a suggestion to create classes for the json and thats what i have done so far, but im still unsure of how to pull the information i need, and im not sure which way i should put lists, as you can see from my code, i have them in 2 different ways to test each way and see what works but im open to suggestions as im not getting anywhere by myself.
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports System.Net
Imports System.IO
Imports BungieNetPlatform
Imports Extensions
Imports System.Text
Public Class STATDEFENSE
Public Property statHash As Object
Public Property value As Integer
Public Property maximumValue As Integer
End Class
Public Class STATINTELLECT
Public Property statHash As Integer
Public Property value As Integer
Public Property maximumValue As Integer
End Class
Public Class STATDISCIPLINE
Public Property statHash As Integer
Public Property value As Integer
Public Property maximumValue As Integer
End Class
Public Class STATSTRENGTH
Public Property statHash As Object
Public Property value As Integer
Public Property maximumValue As Integer
End Class
Public Class STATLIGHT
Public Property statHash As Object
Public Property value As Integer
Public Property maximumValue As Integer
End Class
Public Class STATARMOR
Public Property statHash As Integer
Public Property value As Integer
Public Property maximumValue As Integer
End Class
Public Class STATAGILITY
Public Property statHash As Object
Public Property value As Integer
Public Property maximumValue As Integer
End Class
Public Class STATRECOVERY
Public Property statHash As Integer
Public Property value As Integer
Public Property maximumValue As Integer
End Class
Public Class STATOPTICS
Public Property statHash As Object
Public Property value As Integer
Public Property maximumValue As Integer
End Class
Public Class Stats
Public Property STAT_DEFENSE As List(Of STATDEFENSE)
Public Property STAT_INTELLECT As List(Of STATINTELLECT)
Public Property STAT_DISCIPLINE As STATDISCIPLINE
Public Property STAT_STRENGTH As STATSTRENGTH
Public Property STAT_LIGHT As STATLIGHT
Public Property STAT_ARMOR As STATARMOR
Public Property STAT_AGILITY As STATAGILITY
Public Property STAT_RECOVERY As STATRECOVERY
Public Property STAT_OPTICS As STATOPTICS
End Class
Public Class Customization
Public Property personality As Object
Public Property face As Object
Public Property skinColor As Object
Public Property lipColor As Long
Public Property eyeColor As Long
Public Property hairColor As Object
Public Property featureColor As Object
Public Property decalColor As Long
Public Property wearHelmet As Boolean
Public Property hairIndex As Integer
Public Property featureIndex As Integer
Public Property decalIndex As Integer
End Class
Public Class Dye
Public Property channelHash As Object
Public Property dyeHash As Object
End Class
Public Class Equipment
Public Property itemHash As Object
Public Property dyes As Dye()
End Class
Public Class PeerView
Public Property equipment As Equipment()
End Class
Public Class CharacterBase
Public Property membershipId As String
Public Property membershipType As Integer
Public Property characterId As String
Public Property dateLastPlayed As DateTime
Public Property minutesPlayedThisSession As String
Public Property minutesPlayedTotal As String
Public Property powerLevel As Integer
Public Property raceHash As Object
Public Property genderHash As Object
Public Property classHash As Object
Public Property currentActivityHash As Integer
Public Property lastCompletedStoryHash As Integer
Public Property stats As List(Of Stats)
Public Property customization As Customization
Public Property grimoireScore As Integer
Public Property peerView As PeerView
Public Property genderType As Integer
Public Property classType As Integer
Public Property buildStatGroupHash As Object
End Class
Public Class LevelProgression
Public Property dailyProgress As Integer
Public Property weeklyProgress As Integer
Public Property currentProgress As Integer
Public Property level As Integer
Public Property istep As Integer
Public Property progressToNextLevel As Integer
Public Property nextLevelAt As Integer
Public Property progressionHash As Integer
End Class
Public Class Character
Public Property characterBase As CharacterBase
Public Property levelProgression As LevelProgression
Public Property emblemPath As String
Public Property backgroundPath As String
Public Property emblemHash As Integer
Public Property characterLevel As Integer
Public Property baseCharacterLevel As Integer
Public Property isPrestigeLevel As Boolean
Public Property percentToNextLevel As Double
End Class
Public Class Buckets
Public Property Invisible As Object()
Public Property Item As Object()
Public Property Currency As Object()
End Class
Public Class Currency
Public Property itemHash As Long
Public Property value As Integer
End Class
Public Class Inventory
Public Property buckets As Buckets
Public Property currencies As Currency()
End Class
Public Class Data
Public Property membershipId As String
Public Property membershipType As Integer
Public Property characters As Character()
Public Property inventory As Inventory
Public Property grimoireScore As Integer
Public Property versions As Integer
End Class
Public Class Response
Public Property data As Data
End Class
Public Class MessageData
End Class
Public Class jChars
Public Property Response As Response
Public Property ErrorCode As Integer
Public Property ThrottleSeconds As Integer
Public Property ErrorStatus As String
Public Property Message As String
Public Property MessageData As MessageData
End Class
Module Backend
Public Sub LoadUserJSON(ByVal GameID, ByVal UserName)
Dim BaseURL As String = "http://www.bungie.net/platform/destiny/"
Dim idURL As String = BaseURL & GameID & "/Stats/GetMembershipIdByDisplayName/" & UserName & "/"
Dim Client As New WebClient
Dim JSON_String As String
JSON_String = Client.DownloadString(idURL)
Dim XmlFolder As String = Application.StartupPath & "\XML\"
Try
My.Computer.FileSystem.WriteAllText(XmlFolder & UserName & ".JSON", JSON_String.ToString, False)
Dim json As JObject = JObject.Parse(JSON_String)
MsgBox(json.SelectToken("Response"))
Dim MembershipID As String = json.SelectToken("Response")
LoadAccountJSON(GameID, UserName, MembershipID)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Public Sub LoadAccountJSON(ByVal GameID, ByVal UserName, ByVal MembershipID)
Dim BaseURL As String = "http://www.bungie.net/platform/destiny/"
Dim BaseIconURL As String = "http://www.bungie.net/common/destiny_content/icons/"
Dim XmlFolder As String = Application.StartupPath & "\XML\"
Dim AccountURL As String = BaseURL & GameID & "/Account/" & MembershipID & "/"
Dim json As String = New WebClient().DownloadString(AccountURL)
Dim root As JToken = JToken.Parse(json)
Dim name As String = root.SelectToken("Response.data.characters[0].characterbase[0].characterID")
MsgBox(name)
End Sub
End Module