-
-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dictionary Setup for multi-level json #134
Comments
It looks like the problem is that Dim Fulfillment As New Dictionary
Fulfillment.Add "tracking_number", recordset.Fields("trackingNumber")
Fulfillment.Add "notify_customer", True
Dim Body As New Dictionary
Body.Add "fulfillment", Fulfillment VBA-JSON will handle the convert the nested Dictionaries to the expected JSON string. |
Fantastic, I will give this a try, thank you |
Not sure how to do this in reverse to get the Returning JSON back to 2 different Dictionaries? I am trying but no luck, I can't Cstr the Dictionary so I am stuck.
Is there a way I can just reference the Response without needing to convert back to a dictionary? I tried that as well but no luck.
|
I'm not quite sure what the response looks like, but, for example, to get the id of the first order in the example response below, you would use the following: {
"orders": [
{"id": "123", ...}
]
} Set Response = OrdersClient.GetJson(Resource)
' First id
Debug.Print Response.Data("orders")(1)("id") ' -> "123"
Dim FirstOrder As Dictionary
Set FirstOrder = Response.Data("orders")(1)
Debug.Print FirstOrder("id") ' -> "123"
|
Generally, you shouldn't need to directly use Complex nesting example: [
{
"a": [
[1, "a", {"message": "Howdy!"}]
]
}
] Debug.Print Response.Data(1)("a")(1)(3)("message") ' -> Howdy! |
Yea I figured this out using the Collection object. The code is working very well for me, thank you so much! |
I am struggling with storing something like this in a dictionary object for posting. I need to have the same key more than once for the variants item. Any help you can provide would be awesome! Thank you { |
Hi, You should try something like this. Dim Product As New Dictionary
Product.Add "title", "Burton Custom Freestlye 151"
'...
Dim Variants As New Collection
Dim aVariant As Dictionary
Set aVariant = New Dictionary
aVariant.Add "option1", "First"
'...
Variants.Add aVariant
Set aVariant = New Dictionary
aVariant.Add "option1", "Second"
'...
Variants.Add aVariant
Product.Add "variants", Variants
Dim Body As New Dictionary
Body.Add "product", Product The trick is to remember to use Dictionnary for |
Fantastic, thank you so much for our help! On Tue, Aug 18, 2015 at 4:05 PM Damien Thirion notifications@github.com
|
@DamnDam Thank you so much for the very helpful explanation, especially about which object to use for [ ] & { } |
@timhall , can you please explain me this? |
@timhall , no worries. |
I need to build a dictionary for the body to pass the following to POSTJSON
I am not sure how to do this. Any help would be awesome, thank you
FYI, this is my code, i have it working with a GET so I think my authentication is fine but can't seem to get this POST to work.
(added syntax highlighting)
The text was updated successfully, but these errors were encountered: