github.com/prebid/prebid-server@v0.275.0/util/jsonutil/stringInt.go (about) 1 package jsonutil 2 3 import ( 4 "github.com/buger/jsonparser" 5 ) 6 7 type StringInt int 8 9 func (st *StringInt) UnmarshalJSON(b []byte) error { 10 if len(b) == 0 { 11 return nil 12 } 13 14 if b[0] == '"' { 15 b = b[1 : len(b)-1] 16 } 17 18 if len(b) == 0 { 19 return nil 20 } 21 22 i, err := jsonparser.ParseInt(b) 23 if err != nil { 24 return err 25 } 26 27 *st = StringInt(i) 28 return nil 29 }