-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
binding: support map for map form #1387
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1387 +/- ##
==========================================
+ Coverage 98.48% 98.49% +<.01%
==========================================
Files 41 41
Lines 2046 2057 +11
==========================================
+ Hits 2015 2026 +11
Misses 19 19
Partials 12 12
Continue to review full report at Codecov.
|
if err := setTimeField(inputValue[0], typeField, structField); err != nil { | ||
} else if structFieldKind == reflect.Map { | ||
m := make(map[string]interface{}) | ||
err := json.Unmarshal([]byte(inputValue[0]), &m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think better to use this ptr to real map. It's give you the opportunity to unmarshal from any types of map.
err := json.Unmarshal([]byte(inputValue[0]), &m) | |
err := json.Unmarshal([]byte(inputValue[0]), val.Field(i).Addr().Interface()) |
@appleboy please help me review the pr, thanks! |
I have already added support of map in binding and these tests in my PR #1749 |
Please @javierprovecho @appleboy review the pull request, thanks a lot!
ref: #1362 #398
Idea: declare one
in map[string]interface{}
(MUST), and user inputs-F 'in={"i":1}'
.Support map for map form, can use the curl command:
and the following golang code:
it will output the result: