I use encoding/json
to serialize struct. I'm confused about the output of json.Marshal
function. Does the serialized field content strictly follow the order in the struct definition?
e.g. Here is a struct definition
type MyStruct struct {
Field1 string
Field2 string
}
could the output be {"Field2":"field2","Field1":"field1"}
? Since if the output struct fields out of order, the hash of the serialized content will be uncertain.