mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Convert json numbers to numbers (#5496)
This commit is contained in:
16
pkg/utils/json.go
Normal file
16
pkg/utils/json.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// JSONNumberToNumber converts a JSON number to either a float64 or int64.
|
||||
func JSONNumberToNumber(n json.Number) interface{} {
|
||||
if strings.Contains(string(n), ".") {
|
||||
f, _ := n.Float64()
|
||||
return f
|
||||
}
|
||||
ret, _ := n.Int64()
|
||||
return ret
|
||||
}
|
||||
Reference in New Issue
Block a user