Some vulnerable dependencies upgraded
* golang.org/x/net to v0.8.0 * golang.org/x/crypto to v0.0.0-20220314234659-1baeb1ce4c0b * github.com/aws/aws-sdk-go to v1.34.0 * github.com/prometheus/client_golang to v1.14.0 * k8s.io/client-go to v0.23.0
This commit is contained in:
1 parent
c241c455c5
commit
df2240acbd
3024 files changed
+403882
-96802
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
jpgo
|
||||
/jpgo
|
||||
jmespath-fuzz.zip
|
||||
cpu.out
|
||||
go-jmespath.test
|
||||
+9
-1
@@ -3,7 +3,15 @@ language: go
|
||||
sudo: false
|
||||
|
||||
go:
|
||||
- 1.4
|
||||
- 1.5.x
|
||||
- 1.6.x
|
||||
- 1.7.x
|
||||
- 1.8.x
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
- 1.12.x
|
||||
- 1.13.x
|
||||
|
||||
install: go get -v -t ./...
|
||||
script: make test
|
||||
+81
-1
@@ -4,4 +4,84 @@
|
||||
|
||||
|
||||
|
||||
See http://jmespath.org for more info.
|
||||
go-jmespath is a GO implementation of JMESPath,
|
||||
which is a query language for JSON. It will take a JSON
|
||||
document and transform it into another JSON document
|
||||
through a JMESPath expression.
|
||||
|
||||
Using go-jmespath is really easy. There's a single function
|
||||
you use, `jmespath.search`:
|
||||
|
||||
|
||||
```go
|
||||
> import "github.com/jmespath/go-jmespath"
|
||||
>
|
||||
> var jsondata = []byte(`{"foo": {"bar": {"baz": [0, 1, 2, 3, 4]}}}`) // your data
|
||||
> var data interface{}
|
||||
> err := json.Unmarshal(jsondata, &data)
|
||||
> result, err := jmespath.Search("foo.bar.baz[2]", data)
|
||||
result = 2
|
||||
```
|
||||
|
||||
In the example we gave the ``search`` function input data of
|
||||
`{"foo": {"bar": {"baz": [0, 1, 2, 3, 4]}}}` as well as the JMESPath
|
||||
expression `foo.bar.baz[2]`, and the `search` function evaluated
|
||||
the expression against the input data to produce the result ``2``.
|
||||
|
||||
The JMESPath language can do a lot more than select an element
|
||||
from a list. Here are a few more examples:
|
||||
|
||||
```go
|
||||
> var jsondata = []byte(`{"foo": {"bar": {"baz": [0, 1, 2, 3, 4]}}}`) // your data
|
||||
> var data interface{}
|
||||
> err := json.Unmarshal(jsondata, &data)
|
||||
> result, err := jmespath.search("foo.bar", data)
|
||||
result = { "baz": [ 0, 1, 2, 3, 4 ] }
|
||||
|
||||
|
||||
> var jsondata = []byte(`{"foo": [{"first": "a", "last": "b"},
|
||||
{"first": "c", "last": "d"}]}`) // your data
|
||||
> var data interface{}
|
||||
> err := json.Unmarshal(jsondata, &data)
|
||||
> result, err := jmespath.search({"foo[*].first", data)
|
||||
result [ 'a', 'c' ]
|
||||
|
||||
|
||||
> var jsondata = []byte(`{"foo": [{"age": 20}, {"age": 25},
|
||||
{"age": 30}, {"age": 35},
|
||||
{"age": 40}]}`) // your data
|
||||
> var data interface{}
|
||||
> err := json.Unmarshal(jsondata, &data)
|
||||
> result, err := jmespath.search("foo[?age > `30`]")
|
||||
result = [ { age: 35 }, { age: 40 } ]
|
||||
```
|
||||
|
||||
You can also pre-compile your query. This is usefull if
|
||||
you are going to run multiple searches with it:
|
||||
|
||||
```go
|
||||
> var jsondata = []byte(`{"foo": "bar"}`)
|
||||
> var data interface{}
|
||||
> err := json.Unmarshal(jsondata, &data)
|
||||
> precompiled, err := Compile("foo")
|
||||
> if err != nil{
|
||||
> // ... handle the error
|
||||
> }
|
||||
> result, err := precompiled.Search(data)
|
||||
result = "bar"
|
||||
```
|
||||
|
||||
## More Resources
|
||||
|
||||
The example above only show a small amount of what
|
||||
a JMESPath expression can do. If you want to take a
|
||||
tour of the language, the *best* place to go is the
|
||||
[JMESPath Tutorial](http://jmespath.org/tutorial.html).
|
||||
|
||||
One of the best things about JMESPath is that it is
|
||||
implemented in many different programming languages including
|
||||
python, ruby, php, lua, etc. To see a complete list of libraries,
|
||||
check out the [JMESPath libraries page](http://jmespath.org/libraries.html).
|
||||
|
||||
And finally, the full JMESPath specification can be found
|
||||
on the [JMESPath site](http://jmespath.org/specification.html).
|
||||
+1
-1
@@ -2,7 +2,7 @@ package jmespath
|
||||
|
||||
import "strconv"
|
||||
|
||||
// JmesPath is the epresentation of a compiled JMES path query. A JmesPath is
|
||||
// JMESPath is the representation of a compiled JMES path query. A JMESPath is
|
||||
// safe for concurrent use by multiple goroutines.
|
||||
type JMESPath struct {
|
||||
ast ASTNode
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ func (p *Parser) Parse(expression string) (ASTNode, error) {
|
||||
}
|
||||
if p.current() != tEOF {
|
||||
return ASTNode{}, p.syntaxError(fmt.Sprintf(
|
||||
"Unexpected token at the end of the expresssion: %s", p.current()))
|
||||
"Unexpected token at the end of the expression: %s", p.current()))
|
||||
}
|
||||
return parsed, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user