go-json
go-json copied to clipboard
case-insensitive key matching not working with nested structs
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
I think it was because you may need to change the example input data as well.