Skip to content

Instantly share code, notes, and snippets.

@anthonycvella
Created June 22, 2017 17:57
Show Gist options
  • Save anthonycvella/b02e837a32d967102e596618b05ff038 to your computer and use it in GitHub Desktop.
Save anthonycvella/b02e837a32d967102e596618b05ff038 to your computer and use it in GitHub Desktop.
JSON Optimization for Parsing Vainglory Telemetry Data
' Parses a JSON response and returns an Object
Public Function ParseJSON(data As String) As Object
' First split the string at the "PlayerFirstSpawn" action
Dim splitArray() As String
splitArray() = Split(data, "PlayerFirstSpawn")
' Get the position of the { character which would have been on the line of "PlayerFirstSpawn"
Dim splitTail As String
splitTail = InStrRev(splitArray(0), "{ ")
' Get all characters left of the broken line where "PlayersFirstSpawn" existed
Dim output As String
output = Left(splitArray(0), splitTail)
' Cleanup the final output by removing the remaining , { and then appending a closing JSON ]
Dim finalOutput As String
finalOutput = (Left(output, Len(output) - 3) & "]")
Set ParseJSON = JsonConverter.ParseJSON(finalOutput)
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment