Nullable Data Type for json and database
go get go.portalnesia.com/nullable
package main
import (
"encoding/json"
"fmt"
"go.portalnesia.com/nullable"
)
type JsonType struct {
String nullable.String `json:"string"`
}
func main() {
dataJson := []byte(`{"string":null}`)
var data JsonType
if err := json.Unmarshal(dataJson,&data); err != nil {
panic(err)
}
fmt.Println(data.String)
}