From 59f8f07cff127859a5ba6c143de7122fe7e9ea34 Mon Sep 17 00:00:00 2001 From: RaviKiran Kilingar Date: Sun, 31 Jan 2021 16:47:55 +0530 Subject: [PATCH] Documents the integer constants used in safeInt and provides links --- gjson.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gjson.go b/gjson.go index 4f988d0..5acb848 100644 --- a/gjson.go +++ b/gjson.go @@ -2528,7 +2528,10 @@ func parseInt(s string) (n int64, ok bool) { 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) { + // https://tc39.es/ecma262/#sec-number.min_safe_integer || https://tc39.es/ecma262/#sec-number.max_safe_integer if f < -9007199254740991 || f > 9007199254740991 { return 0, false }