Skip to content
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

Support Indexed Arrays #71

Merged
merged 10 commits into from
Sep 19, 2021
Merged

Support Indexed Arrays #71

merged 10 commits into from
Sep 19, 2021

Conversation

siemensikkema
Copy link
Member

@siemensikkema siemensikkema commented Sep 1, 2021

Supports indexed array elements when decoding and encoding form data (fixes #67, replaces #69).

Indicating that a value belongs to an array can now be done by appending [0], [1], etc. to the name, as an alternative to the already supported []. This allows for representing nested data inside elements in an array.

For instance, let matrix: [[Int]] = [[42,21]] can now be represented using part names matrix[0][0] and matrix[0][1]. Without indexed array elements there is no way to distinguish the above from [[42],[21]].

Note: FormDataEncoder now also includes indexes for array types in its output.

Credits go to @chocoford for identifying the issue, the test cases and the initial PR!

Refactor implementation to more closely follow the intended usage and
therefore support, among other things, decoding top level optionals.
Removes `fatalError`s in favor of (presumably) intended implementations.

- add support for passing in `userInfo`
- add test for decoding optional
@siemensikkema siemensikkema force-pushed the feature/support-indexed-arrays branch from 95056cb to 505c393 Compare September 3, 2021 08:40
@siemensikkema siemensikkema force-pushed the feature/support-indexed-arrays branch from 505c393 to 6be565c Compare September 3, 2021 09:20
@siemensikkema siemensikkema changed the title Add support for indexed arrays Support Indexed Arrays Sep 3, 2021
@siemensikkema siemensikkema added the semver-minor Contains new API label Sep 3, 2021
@siemensikkema siemensikkema linked an issue Sep 3, 2021 that may be closed by this pull request
@siemensikkema siemensikkema force-pushed the feature/support-indexed-arrays branch from 6be565c to dbd9c55 Compare September 6, 2021 13:09
@siemensikkema siemensikkema marked this pull request as ready for review September 6, 2021 13:19
Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from feature/refactor-coders to main September 19, 2021 12:31
@siemensikkema siemensikkema merged commit 30f5343 into main Sep 19, 2021
@siemensikkema siemensikkema deleted the feature/support-indexed-arrays branch September 19, 2021 13:12
@VaporBot
Copy link

These changes are now available in 4.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor Contains new API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to decode nested multipart array.
3 participants