VBA-tools / VBA-JSON

JSON conversion and parsing for VBA
MIT License
1.77k stars 573 forks source link

Multi Level Json #85

Closed murtazay closed 6 years ago

murtazay commented 6 years ago

Hi,

I am trying to get some data from a multi level json via http.

The link in question is https://api.iextrading.com/1.0/stock/aapl/batch?types=quote,stats

Now if I (after getting the json and assigning it) do Json("quote")("symbol") it works but if the quote and symbol are replaced by variables then it fails and shows an empty match. That is to say Json(ref)(field).

Already checked the values of ref and field and they are correct.

I don't understand why this is happening.

timhall commented 6 years ago

HI @murtazay can you provide a sample of your code? I wasn't able to repro with the following.

Sub Testing()
    Dim Value As Dictionary
    Set Value = JsonConverter.ParseJson("{""a"":{""b"":""c""}}")

    Debug.Print Value("a")("b")

    Dim A
    Dim B

    A = "a"
    B = "b"

    Debug.Print Value(A)(B)

    Dim AlsoA As String
    Dim AlsoB As Variant

    AlsoA = "a"
    AlsoB = "b"

    Debug.Print Value(AlsoA)(AlsoB)
End Sub

Happy to reopen with some more information.