3
0

add(crm,sam): parseJSONText util func

This commit is contained in:
Tit Petric 2018-09-02 22:38:38 +02:00
parent 7b271da835
commit 29c9a8621b
2 changed files with 18 additions and 0 deletions

View File

@ -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 == "" {

View File

@ -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 == "" {