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
Hi, during json.Marshal, a 0 value for an int is considered as empty, and the corresponding struct field isn't even made a part of the output. For example, if this is my struct
type some struct {
Name string `json:"name,omitempty"`
Value int64 `json:"value,omitempty"`
}
The value of string(bodyContent) will be {"name":"blah"}. But when I use the following value
someEx := &some{
Name: "blah",
Value: 1,
}
Then the value of string(bodyContent) is {"name":"blah","value":1}.
I think that even if the value is 0, it can be needed by some applications, is it possible to pass it along?
The text was updated successfully, but these errors were encountered:
Hi, during json.Marshal, a 0 value for an int is considered as empty, and the corresponding struct field isn't even made a part of the output. For example, if this is my struct
And this is where I'll marshal it:
The value of
string(bodyContent)
will be{"name":"blah"}
. But when I use the following valueThen the value of
string(bodyContent)
is{"name":"blah","value":1}
.I think that even if the value is 0, it can be needed by some applications, is it possible to pass it along?
The text was updated successfully, but these errors were encountered: