Skip to content

encoding/json: bug in json.Unmarshal if keys in JSON differ only by case #26687

Closed
@AyushG3112

Description

@AyushG3112

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

Playground and go version go1.10.2 linux/amd64

What operating system and processor architecture are you using (go env)?

Playground and:

GOARCH="amd64"
GOBIN=""
GOCACHE= **REDACTED**
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH= **REDACTED**
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build198743377=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Here is the input json

{"a" :"This is value for ASmall", "A": "This is value for ACaps"}

In Playground Link 1, my target struct only has a field corresponding to the a key.

In Playground Link 2, my target struct has fields corresponding to both a and A.

What did you expect to see?

In Link 1, I expected to see the value printed to be This is value for ASmall which corresponds to the value of key a

What did you see instead?

The value printed was This is value for ACaps which corresponds to the value of key A.
Link 2 worked fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions