[Solved] Go JSON Naming strategy about extends


Please, add your convert code here. The code below works fine.

type BaseModel struct {
    Id          string    `json:"id"`
    CreatedTime time.Time `json:"createdTime"`
    UpdatedTime time.Time `json:"updatedTime"`
    Deleted     bool      `json:"deleted"`
}

type Category struct {
    BaseModel
    Parent    string `json:"parent"`
    Name      string `json:"name"`
    IconClass string `json:"iconClass"`
    Mark      string `json:"mark"`
}

func main() {
    data, err := json.Marshal(Category{})
    if err != nil {
        return
    }

    fmt.Println(string(data[:]))
}

Output:

{"id":"","createdTime":"0001-01-01T00:00:00Z","updatedTime":"0001-01-01T00:00:00Z","deleted":false,"parent":"","name":"","iconClass":"","mark":""}

solved Go JSON Naming strategy about extends