Golang encoding/json.Number.Int64 function example
package encoding/json
Int64 returns the number as an int64.
Golang encoding/json.Number.Int64 function usage example
func (j *Json) Float64() (float64, error) {
switch j.data.(type) {
case json.Number:
return j.data.(json.Number).Int64() // <---- here
case float32, float64:
return reflect.ValueOf(j.data).Float(), nil
case int, int8, int16, int32, int64:
return float64(reflect.ValueOf(j.data).Int()), nil
case uint, uint8, uint16, uint32, uint64:
return float64(reflect.ValueOf(j.data).Uint()), nil
}
return 0, errors.New("invalid value type")
}
Reference :
Advertisement
Something interesting
Tutorials
+7.9k Golang : Trim everything onward after a word
+6.7k Golang : Experimental emojis or emoticons icons programming language
+10.4k Golang : Meaning of omitempty in struct's field tag
+14.4k Android Studio : Use image as AlertDialog title with custom layout example
+11.5k Golang : Generate DSA private, public key and PEM files example
+8.4k Golang : Generate Datamatrix barcode
+62.7k Golang : Convert HTTP Response body to string
+9.7k Golang : List available AWS regions
+16.4k Golang : How to implement two-factor authentication?
+8.3k Swift : Convert (cast) Character to Integer?
+9.7k Golang : Find correlation coefficient example
+5.5k Golang : If else example and common mistake