VBA-tools/VBA-JSON

bug with brackets

RaunakThomas opened this issue · 3 comments

Dim Json As Object
Set Json = JsonConverter.ParseJson("{""a"":123,""b"":[{""Name"":""abc""},{""Name"":""cde""}]}")
Debug.Print (Json("a"))
Debug.Print (Json("b"))

I'm not sure why the first print statement works whereas the second one doesn't

Your "b" data is contained as two elements in an array (the square brackets) so you have to address the elements of that array to return results. These statements worked for me: Debug.Print (Json("b")(1)("Name")) 'gives abcDebug.Print (Json("b")(2)("Name")) 'gives cde Hope it helps! On Thursday, December 9, 2021, 04:22:46 PM EST, Raunak Thomas @.***> wrote: Dim Json As Object Set Json = JsonConverter.ParseJson("{""a"":123,""b"":[{""Name"":""abc""},{""Name"":""cde""}]}") Debug.Print (Json("a")) Debug.Print (Json("b")) I'm not sure why the first print statement works whereas the second one doesn't — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Tremendously helpful - thank you. Was suffering through this today and your answer solved my problem!