I'm trying to parse the JSON data from API written in the sheet1 cells (B11:B15) into excel using VBA:
API in cell B11 =

Api are the same and change only the ID
Here is the code that i'm using:
Option Explicit
Public r As Long, c As Long
Sub readValues()
Dim sJSONString As String
Dim ws As Worksheet
Dim a As Integer
Dim ID As String
Dim I As Integer
For a = 11 To 15
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", Foglio1.Cells(a, 2), False
.send
sJSONString = .responseText
'MsgBox sJSONString
End With
Dim JSON As Object, item As Object
ID = Foglio1.Cells(a, 1)
Set JSON = JsonConverter.ParseJson(sJSONString)("data")(ID)("statistics")("all")
r = 1: c = 1
EmptyDict JSON
Next a
End Sub
Public Sub EmptyDict(ByVal dict As Object)
Dim key As Variant, item As Object
Select Case TypeName(dict)
Case "Collection"
For Each item In dict
c = c
r = r + 1
EmptyDict item
Next
Case "Dictionary"
For Each key In dict
If TypeName(dict(key)) = "Collection" Then
EmptyDict (dict(key))
Else
With ThisWorkbook.Worksheets("foglio1")
.Cells(r + 9, c + 5) = (key)
.Cells(r + 10, c + 5) = dict(key)
End With
c = c + 1
End If
Next
End Select
End Sub
the code works fine but it cant loop the 5 ID APIs; the code writes all 5 items in the same row 11. in addition i would like to write the "all", "rating" objects and the "nickname"and "last battle time" in each row. Could someone help me ? Thank you
