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

Different situation #15

Closed
wants to merge 3 commits into from
Closed

Different situation #15

wants to merge 3 commits into from

Conversation

godblesshugh
Copy link
Contributor

test := map[string]interface{}{“test1”: 0, “test2”: false,}
EncodeToString needs to be like this:
test1=0&test2=false
not:
test1=&test2=

{“test1”: 0, “test2”: false} EncodeToString
need to
test1=0&test2=false
not
test1=&test2=
@ajg ajg self-assigned this Jul 17, 2017
@godblesshugh
Copy link
Contributor Author

using form as default tag, json will be used when there's no form tag.

@ajg
Copy link
Owner

ajg commented Jul 18, 2017

@godblesshugh, regarding the first issue, take a look at this branch I just pushed: https://github.com/ajg/form/tree/encode-to-with#zero-values; that ought to solve your problem (missing zero values) more conveniently than using NewEncoder. Let me know if it doesn't.

@ajg
Copy link
Owner

ajg commented Jul 18, 2017

Relevant PR: #16

@godblesshugh
Copy link
Contributor Author

@ajg yes, zero-values problem solved, thanks.
What about this one:
using form as default tag, json will be used when there's no form tag.

@ajg
Copy link
Owner

ajg commented Jul 21, 2017

@godblesshugh, regarding the tag issue: I'm not sure it's a good idea to automatically fall back to a json tag if there is no form tag; that could have unintended consequences. Making the tag name configurable would be safer and backwards compatible. Would that be good enough for your case?

@godblesshugh
Copy link
Contributor Author

@ajg that will do, for my case, content in form tag always be the same with those in json tag. Making the tag name configurable is a more suitable solution 👏🏻

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 this pull request may close these issues.

None yet

2 participants