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

Serialize composite []string with empty square brackets #27

Open
Integralist opened this issue Sep 17, 2021 · 2 comments
Open

Serialize composite []string with empty square brackets #27

Integralist opened this issue Sep 17, 2021 · 2 comments

Comments

@Integralist
Copy link

👋🏻 I have an API that expects data to be sent like so:

services[]=A&services[]=B

How can I achieve this?

Currently the default behaviour appears to number each element within the slice.

I see there's a DelimitWith method but that doesn't quite achieve what I need (e.g. DelimitWith('|')):

services|0=A&services|1=B

Is there a custom unmarshal method I can define that might help encode the data how I need it?

Thanks!

@kokizzu
Copy link

kokizzu commented Jun 9, 2022

just use https://github.com/google/go-querystring

@Integralist
Copy link
Author

That's exactly what I ended up doing 🙂

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

No branches or pull requests

2 participants