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

Feature: support "natural" maps #52

Open
mihaiav opened this issue Feb 26, 2021 · 0 comments
Open

Feature: support "natural" maps #52

mihaiav opened this issue Feb 26, 2021 · 0 comments

Comments

@mihaiav
Copy link

mihaiav commented Feb 26, 2021

It seems that map types are not supported. E.g. map[interface{}]interface{} or map[string]string. Is this the expected behaviour?

Play

package main

import (
	"fmt"
	"github.com/go-playground/form"
	"net/url"
	"reflect"
)

func main() {
	dec := form.NewDecoder()

	req := url.Values{"a": []string{"a"}, "b": []string{"b"}, "c": []string{"1"}}

	v := map[interface{}]interface{}{
		"a": "",
		"b": "",
		"c": 0,
	}

	expected := map[interface{}]interface{}{
		"a": "a",
		"b": "b",
		"c": 1,
	}
	if err := dec.Decode(&v, req); err != nil {
		panic(err)
	}
	if !reflect.DeepEqual(v, expected) {
		fmt.Printf("expected\n %#v\n received\n %#v", expected, v)
	}
}

@mihaiav mihaiav changed the title maps decoding fails silently Feature: support "natural" maps Apr 21, 2021
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

1 participant