Parse JSON with VBA (Access 2010) Parse JSON with VBA (Access 2010) json json

Parse JSON with VBA (Access 2010)


If you are using this json parser https://github.com/VBA-tools/VBA-JSON, use this code

Private Sub IterateDictionary(poDict As Dictionary)    Dim key As Variant    For Each key In poDict.Keys()        If TypeName(poDict(key)) = "Dictionary" Then            Debug.Print key            IterateDictionary poDict(key)        Else            Debug.Print key, poDict(key)        End If    NextEnd Sub

EDIT:You have to modify the debug.print with whatever process you want to do. To use this from your code put this line after MsgBox.

IterateDictionary Json


You could also string parse. For example, if after key pairs for the rates:

Option ExplicitPublic Sub GetValues()    Dim s As String, rates(), i As Long    s = "{""timestamp"": 1465843806,""base"": ""CAD"",""rates"": {""AED"": 2.87198141,""AFN"": 54.21812828,""ALL"": 95.86530071,""AMD"": 374.48549935,""ANG"": 1.39861507}}"    rates = Array("AED", "AFN", "ALL", "AMD", "ANG")    For i = LBound(rates) To UBound(rates)        Debug.Print rates(i) & ":" & GetRate(s, rates(i))    Next iEnd SubPublic Function GetRate(ByVal s As String, ByVal delimiter As String) As String    GetRate = Replace(Split(Split(s, delimiter & Chr$(34) & Chr$(58))(1), Chr$(44))(0), Chr$(125), vbNullString)End Function

output