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

toFormData should (optionally?) support array serialization (w/o [] suffix) #4698

Closed
plehnen opened this issue May 9, 2022 · 2 comments · Fixed by #4704
Closed

toFormData should (optionally?) support array serialization (w/o [] suffix) #4698

plehnen opened this issue May 9, 2022 · 2 comments · Fixed by #4704

Comments

@plehnen
Copy link

plehnen commented May 9, 2022

Is your feature request related to a problem? Please describe.

While trying to migrate to the new FormData autogeneration (by using postForm or setting Content-Type to multipart) I realized arrays won't work anymore. An 'arr' proprety with two entries will be converted to name="arr.0" and name="arr.1" in the payload.
I saw in the source-code that once the name has a suffix like '[]' it will post it as such. But our springboot backend wants the key to be 'arr' (not 'arr[]') and our client-side typescript interface has a key named 'arr' and not 'arr[]' either.

Describe the solution you'd like

Plain arrays should also be send automatically, without the need to put '[]' to its name. If that's a breaking change, make it optional via options.

Describe alternatives you've considered

Springboot can't parse the default 'arr.0', 'arr.1' format. And adding '[]' to the type, the client-side object and the desired property in the backend is not an ideal solution.

In typescript properties of types/interfaces usually don't have a '[]' suffix. But the whole point of migrating to this new feature is to have type-safe services with a typed payload instead of just any 'FormData' object.

Additional context

@startjava
Copy link

startjava commented Feb 28, 2024

#6266
@plehnen

same question , same spring boot envirment

@startjava
Copy link

@DigitalBrainJS
#4704
The contents of this URL still do not solve the problem of receiving array parameters in the springboot environment. In springboot, the foreground URL cannot have [] and., but the URL does not completely disable [] and. option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants