-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Add .indexInBrackets array serialization option for URL parameters #3516
Add .indexInBrackets array serialization option for URL parameters #3516
Conversation
95eb534
to
b085ad3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this looks great! Just a few doc formatting suggestions and some naming and this should be all set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed one use site of the updated naming. Once that's updated I can trigger the test suite.
fac8ac5
to
db327e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…3516) * Add the indexInBrackets option to URLEncoding * Add the indexInBrackets option to URLEncodedFormEncoder * Add .indexInBrackets tests for structs and classes * Address PR comments regarding .indexInBrackets serialization
Issue Link 🔗
Goals ⚽
There is no real specification for how to encode URL parameters like arrays and dictionaries.
For
["foo": ["a", 1, true, ["bar": 2], ["qux": 3], ["quy": ["quz": 3]]]]default
.bracketsencode is:foo[]=a&foo[]=1&foo[]=1&foo[][bar]=2&foo[][qux]=3&foo[][quy][quz]=3.noBracketsencode is:foo=a&foo=1&foo=1&foo[bar]=2&foo[qux]=3&foo[quy][quz]=3jQuery >=1.4 and Node.js package query-string provide index style:
foo[0]=a&foo[1]=1&foo[2]=1&foo[3][bar]=2&foo[4][qux]=3&foo[5][quy][quz]=3Implementation Details 🚧
A new
ArrayEncodingenumeration case is added to bothURLEncodingandURLEncodedFormEncoder. The cases now are.bracketsand.noBracketsand.indexInBrackets. ThearrayEncodingoption passed to the initializer is used to control the array key serialization inURLEncodedFormEncoderandURLEncoding.Testing Details 🔍
New tests were added to the
ParameterEncoderTestsandParameterEncodingTestssuites. They follow the same naming convention but with an appendedWithIndexInBracketssuffix.Note:
This PR continues the work started at #3015.