forked from mirror/gjson
Merge pull request #203 from rkilingr/documentation/json-integers
Creates a constant for maximum and minimum JSON Integers and documents them
This commit is contained in:
commit
b977acbb8b
3
gjson.go
3
gjson.go
|
@ -2528,7 +2528,10 @@ func parseInt(s string) (n int64, ok bool) {
|
||||||
return n, true
|
return n, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// safeInt validates a given JSON number
|
||||||
|
// ensures it lies within the minimum and maximum representable JSON numbers
|
||||||
func safeInt(f float64) (n int64, ok bool) {
|
func safeInt(f float64) (n int64, ok bool) {
|
||||||
|
// https://tc39.es/ecma262/#sec-number.min_safe_integer || https://tc39.es/ecma262/#sec-number.max_safe_integer
|
||||||
if f < -9007199254740991 || f > 9007199254740991 {
|
if f < -9007199254740991 || f > 9007199254740991 {
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue