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

case-insensitive key matching not working with nested structs #470

Open
liberize opened this issue Sep 11, 2023 · 1 comment
Open

case-insensitive key matching not working with nested structs #470

liberize opened this issue Sep 11, 2023 · 1 comment

Comments

@liberize
Copy link

liberize commented Sep 11, 2023

example:

package main

import (
	"fmt"
	"github.com/goccy/go-json"
)

type Base struct {
	B string `json:"bb"`
}

type Test struct {
	Base
	A string `json:"aA"`
}

func main() {
	b := &Test{}
	err := json.Unmarshal([]byte(`{"Aa":"111","Bb":"222"}`), b)
	fmt.Printf("b: %v, err: %v\n", b, err)
}

prints:

b: &{{} }, err: <nil>

change json:"bB" to json:"bb" then it works:

b: &{{222} 111}, err: <nil>

tested with go 1.14.5 and go-json master

@xin-tsla
Copy link

xin-tsla commented Oct 7, 2023

I think it was because you may need to change the example input data as well.

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