mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-19 05:10:02 +02:00
Adding src/utils/json.go
This commit is contained in:
parent
dd6d636a43
commit
32faaaf418
1 changed files with 17 additions and 0 deletions
17
src/utils/json.go
Normal file
17
src/utils/json.go
Normal file
|
|
@ -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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue