I have seen a lot of examples showing how to parse json strings with VBA-JSON, however I would like to know how to create a JSON object from scratch using this library.
I have started with:
Set Json = JsonConverter.ParseJson("{}")
Json("key") = "value"
And this works as expected.
However, if I want to create a nested object, for example:
Json("new_key")(1)("value") = 1
Json("new_key")(2)("foo") = "bar"
Does not output the expected: {"new_key":[{"value": 1}, {"foo": "bar"}]}
Is this possible to achieve with this library? Or is there another way to do it?
Thanks
You can use Dictionary and Collection in VBA. After that convert them to Json. This is an example:
And this is output:
Something like this: