add(crm,sam): parseJSONText util func
This commit is contained in:
parent
7b271da835
commit
29c9a8621b
@ -4,10 +4,19 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/jmoiron/sqlx/types"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var truthy = regexp.MustCompile("^\\s*(t(rue)?|y(es)?|1)\\s*$")
|
||||
|
||||
func parseJSONText(s string) (types.JSONText, error) {
|
||||
result := &types.JSONText{}
|
||||
err := errors.Wrap(result.Scan(s), "error when parsing JSONText")
|
||||
return *result, err
|
||||
}
|
||||
|
||||
// parseInt64 parses an string to int64
|
||||
func parseInt64(s string) int64 {
|
||||
if s == "" {
|
||||
|
||||
@ -4,10 +4,19 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/jmoiron/sqlx/types"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var truthy = regexp.MustCompile("^\\s*(t(rue)?|y(es)?|1)\\s*$")
|
||||
|
||||
func parseJSONText(s string) (types.JSONText, error) {
|
||||
result := &types.JSONText{}
|
||||
err := errors.Wrap(result.Scan(s), "error when parsing JSONText")
|
||||
return *result, err
|
||||
}
|
||||
|
||||
// parseInt64 parses an string to int64
|
||||
func parseInt64(s string) int64 {
|
||||
if s == "" {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user