Nested in Nested post args not working as expected.
See original GitHub issueNot sure how to display this properly so here it is:
I am parsing post args for a POST request as follows:
post_args = {
'item_1': input_fields.Str(),
'item_2': input_fields.Str(),
'item3: input_fields.Nested({
'0.00': input_fields.Nested({'someItem': input_fields.Str(), ... }),
'0.10': input_fields.Nested({'someItem': input_fields.Str(), ... }),
'0.20': input_fields.Nested({'someItem': input_fields.Str(), ... })
})
}
When parsed I expect to get the following:
parsed_args = {
'item1' : 'some string',
'item2': 'some other string',
'item3': {
'0.00': {'someItem': 'some useful string'},
'0.10': {'someItem': 'some useful string'},
'0.20': {'someItem': 'some useful string'}
}
}
But instead it puts item3 nested values into a dictionary with key 0 and then the nested items as follows:
parsed_args = {
'item1' : 'some string',
'item2': 'some other string',
'item3': {
'0': {
'0.00': {'someItem': 'some useful string'},
'0.10': {'someItem': 'some useful string'},
'0.20': {'someItem': 'some useful string'}
}
}
}
Am I doing something wrong? Am I missing anything ? Is this supposed to happen?
I can confirm that the data received in JSON are in the right structure.
Any ideas?
Update I ve noticed this happens when the keys are strings of decimals i.e 0.00 0.10 0.20 but still why can’t I do that?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
POST Request with nested arguments - Stack Overflow
Basically, in HTTP there is no 'nesting' of parameters per se. ... not (at least not "natively") is multiple values for query parameters....
Read more >Nested params option not works as expected #2534 - GitHub
Describe the bug Nested params option not works as expected. ... POST requests take in the data on the body, data in axios'...
Read more >Working with nested data - Splunk Documentation
Extract a nested map from one field and add it to another field · Prepare the body field so that it can be...
Read more >Nested bash if then else script not working as expected to ...
To use wildcards when passing arguments to the script, don't quote the wildcard: script "John's file*.mp4" -> script "John's file"*.mp4 .
Read more >Prisma Client API (Reference)
You must re-generate the Prisma Client each time you add or rename a data source. ... User" AS "t0" INNER JOIN "public". ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m afraid my workaround above will work and the issue is the dot in the input data.
Related marshmallow issue : https://github.com/marshmallow-code/marshmallow/issues/1506.
Looks like this is due to marshmallow interpreting the dot in the decimal string as a subpath delimiter.
I’m not sure this behaviour is correct, so it might be a bug.
You might be able to circumvent it by setting a name without dot and using attribute/data_key to get back your dotted name, but that’s not ideal.
Untested code: