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

encoding/json: Capitalization in field tags not handled correctly when unmarshalling #28190

ToadKing opened this issue Oct 13, 2018 · 2 comments


Copy link

If you try to unmarshal a JSON string with entries with identical keys but different cases, the correct key may not be chosen.

Test Program:

package main

import (

type testStruct struct {
	Testone string `json:"testone"`

func main() {
	testStr := `
		"testone": "one",
		"testOne": "two"

	var s testStruct
	json.Unmarshal([]byte(testStr), &s)
	fmt.Printf("testone = %s\n", s.Testone)

Expected output: testone = one
Actual output: testone = two

Tested on Go Playground - go1.11.1

Copy link

mvdan commented Oct 13, 2018

Dup of #14750?

Copy link

Looks like it, closing this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

3 participants