diff --git a/get.go b/get.go index 73de642..f224ad4 100644 --- a/get.go +++ b/get.go @@ -32,3 +32,10 @@ func GetTime(val null.Time) (res time.Time) { } return val.Time } + +func GetJSON(val null.JSON) (res []byte) { + if !val.Valid { + return + } + return val.JSON +} diff --git a/set.go b/set.go index 0709375..ec44177 100644 --- a/set.go +++ b/set.go @@ -32,3 +32,10 @@ func SetTime(val time.Time) null.Time { Valid: true, } } + +func SetJSON(val []byte) null.JSON { + return null.JSON{ + JSON: val, + Valid: true, + } +}