Skip to content

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.

2 participants