Answers for "golang json omitempty struct"

0

golang json omitempty struct

import (
    "fmt"
    "github.com/clarketm/json" // drop-in replacement for `encoding/json`
)

type Result struct {
    Data   MyStruct `json:"data,omitempty"`
    Status string   `json:"status,omitempty"`
    Reason string   `json:"reason,omitempty"`
}

j, _ := json.Marshal(&Result{
    Status: "204",
    Reason: "No Content",
})

fmt.Println(string(j))
Posted by: Guest on September-28-2021

Code answers related to "golang json omitempty struct"

Code answers related to "Javascript"

Browse Popular Code Answers by Language