fr
fr

Question from the Go test

Medium

What is the difference in behavior of the omitempty attribute between an int field and an *int field during JSON marshaling?

type Data struct {
    Value int  `json:"val,omitempty"`
    Ptr   *int `json:"ptr,omitempty"`
}

// Soit d := Data{Value: 0, Ptr: nil}
Author: WeLoveDevsStatus: PublishedQuestion not yet passed
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!