You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?:
package main
import (
"json"
"fmt"
)
type Message struct {
test string
test2 string
}
func main() {
var m = Message{"t1", "t22"}
output, _ := json.Marshal(m)
fmt.Println(string(output))
}
What is the expected output?:
{"Test":"t1","Test2":"t22"}
What do you see instead?:
{}
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
linux/Fedora
Which revision are you using? (hg identify)
d5785050f61d (release-branch.r59) release/release.r59
Additional remarks:
By changing Message to:
type Message struct {
Test string
Test2 string
}
It works correclty: {"Test":"t1","Test2":"t22"}
The text was updated successfully, but these errors were encountered:
Because Unmarshal cannot write to lower case fields,
Marshal ignores them for symmetry. They are only
exposed by reflect for easier debugging with fmt.Print.
If you need a field with a lower-case name in the
json output you can write
type Message struct {
Test string `json:"test"`
}
Russ
by hendrik.demolder:
The text was updated successfully, but these errors were encountered: