Skip to content

Commit

Permalink
Updated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Sep 1, 2021
1 parent 52919fa commit 160fb9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ result.Str // holds the string
result.Num // holds the float64 number
result.Raw // holds the raw json
result.Index // index of raw value in original json, zero means index unknown
result.Indexes // Indexes contains the indexes of the elements returned by a query containing the '#' character
result.Indexes // Indexes of all the elements that match on a `#(...)#` query

```

There are a variety of handy functions that work on a result:
Expand Down
8 changes: 5 additions & 3 deletions gjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type Result struct {
Num float64
// Index of raw value in original json, zero means index unknown
Index int
// Indexes contains the Indexes of the elements returned by a query containing the '#' character
// Indexes of all the elements that match on a `#(...)#` query.
Indexes []int
}

Expand Down Expand Up @@ -1511,7 +1511,8 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
raw = res.String()
}
jsons = append(jsons, []byte(raw)...)
indexes = append(indexes, res.Index+parentIndex)
indexes = append(indexes,
res.Index+parentIndex)
k++
}
}
Expand Down Expand Up @@ -2472,7 +2473,8 @@ func parseInt(s string) (n int64, ok bool) {
// 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
// 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
}
Expand Down

0 comments on commit 160fb9d

Please sign in to comment.