diff --git a/src/utils/json.go b/src/utils/json.go new file mode 100644 index 0000000..17feeba --- /dev/null +++ b/src/utils/json.go @@ -0,0 +1,17 @@ + +package utils + +// JsonGetInt64 +// performs float64 (json numbers are always float64) +// type assertion and casts to int64. +// +// if the type assertion fails, the function defaults 0 (zero). +// --------------------------------------------------------- + +func JsonGetInt64(input interface{}) (int64) { + v, res := input.(float64) + if res { + return (int64) (v) + } + return 0 +}