mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 05:21:57 +00:00
23 lines
328 B
Go
23 lines
328 B
Go
package utils
|
|
|
|
import "encoding/json"
|
|
|
|
type NullString struct {
|
|
Set bool
|
|
Value *string
|
|
}
|
|
|
|
func (ns *NullString) UnmarshalJSON(b []byte) error {
|
|
ns.Set = true
|
|
if string(b) == "null" {
|
|
ns.Value = nil
|
|
return nil
|
|
}
|
|
var s string
|
|
if err := json.Unmarshal(b, &s); err != nil {
|
|
return err
|
|
}
|
|
ns.Value = &s
|
|
return nil
|
|
}
|