mirror of https://github.com/tidwall/gjson.git
Compare commits
4 Commits
22971ffce5
...
58e73b3802
Author | SHA1 | Date |
---|---|---|
Andreas Deininger | 58e73b3802 | |
Josh Baker | 2ba56cc086 | |
rustfix | 5d0d40c89f | |
Andreas Deininger | 236e6a50b2 |
|
@ -14,12 +14,12 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: ^1.13
|
go-version: ^1.13
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# GJSON Path Syntax
|
# GJSON Path Syntax
|
||||||
|
|
||||||
A GJSON Path is a text string syntax that describes a search pattern for quickly retreiving values from a JSON payload.
|
A GJSON Path is a text string syntax that describes a search pattern for quickly retrieving values from a JSON payload.
|
||||||
|
|
||||||
This document is designed to explain the structure of a GJSON Path through examples.
|
This document is designed to explain the structure of a GJSON Path through examples.
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@ This document is designed to explain the structure of a GJSON Path through examp
|
||||||
- [Multipaths](#multipaths)
|
- [Multipaths](#multipaths)
|
||||||
- [Literals](#literals)
|
- [Literals](#literals)
|
||||||
|
|
||||||
The definitive implemenation is [github.com/tidwall/gjson](https://github.com/tidwall/gjson).
|
The definitive implementation is [github.com/tidwall/gjson](https://github.com/tidwall/gjson).
|
||||||
Use the [GJSON Playground](https://gjson.dev) to experiment with the syntax online.
|
Use the [GJSON Playground](https://gjson.dev) to experiment with the syntax online.
|
||||||
|
|
||||||
## Path structure
|
## Path structure
|
||||||
|
|
||||||
A GJSON Path is intended to be easily expressed as a series of components seperated by a `.` character.
|
A GJSON Path is intended to be easily expressed as a series of components separated by a `.` character.
|
||||||
|
|
||||||
Along with `.` character, there are a few more that have special meaning, including `|`, `#`, `@`, `\`, `*`, `!`, and `?`.
|
Along with `.` character, there are a few more that have special meaning, including `|`, `#`, `@`, `\`, `*`, `!`, and `?`.
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ The following GJSON Paths evaluate to the accompanying values.
|
||||||
|
|
||||||
### Basic
|
### Basic
|
||||||
|
|
||||||
In many cases you'll just want to retreive values by object name or array index.
|
In many cases you'll just want to retrieve values by object name or array index.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
name.last "Anderson"
|
name.last "Anderson"
|
||||||
|
|
6
gjson.go
6
gjson.go
|
@ -1252,7 +1252,7 @@ func parseObject(c *parseContext, i int, path string) (int, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// matchLimit will limit the complexity of the match operation to avoid ReDos
|
// matchLimit will limit the complexity of the match operation to avoid ReDos
|
||||||
// attacks from arbritary inputs.
|
// attacks from arbitrary inputs.
|
||||||
// See the github.com/tidwall/match.MatchLimit function for more information.
|
// See the github.com/tidwall/match.MatchLimit function for more information.
|
||||||
func matchLimit(str, pattern string) bool {
|
func matchLimit(str, pattern string) bool {
|
||||||
matched, _ := match.MatchLimit(str, pattern, 10000)
|
matched, _ := match.MatchLimit(str, pattern, 10000)
|
||||||
|
@ -2194,7 +2194,7 @@ func unescape(json string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Less return true if a token is less than another token.
|
// Less return true if a token is less than another token.
|
||||||
// The caseSensitive paramater is used when the tokens are Strings.
|
// The caseSensitive parameter is used when the tokens are Strings.
|
||||||
// The order when comparing two different type is:
|
// The order when comparing two different type is:
|
||||||
//
|
//
|
||||||
// Null < False < Number < String < True < JSON
|
// Null < False < Number < String < True < JSON
|
||||||
|
@ -3353,7 +3353,7 @@ func (t Result) Path(json string) string {
|
||||||
goto fail
|
goto fail
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(json[t.Index:], t.Raw) {
|
if !strings.HasPrefix(json[t.Index:], t.Raw) {
|
||||||
// Result is not at the JSON index as exepcted.
|
// Result is not at the JSON index as expected.
|
||||||
goto fail
|
goto fail
|
||||||
}
|
}
|
||||||
for ; i >= 0; i-- {
|
for ; i >= 0; i-- {
|
||||||
|
|
Loading…
Reference in New Issue