-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplfied match result to []interface{} and added extension for acces…
…ss to wildcards values of a match
- Loading branch information
JanErik Keller
committed
Oct 24, 2017
1 parent
45ad7c3
commit 463a233
Showing
8 changed files
with
596 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,13 +47,13 @@ func ExampleGet_wildcard() { | |
os.Exit(1) | ||
} | ||
|
||
for wildcards, value := range welcome.(jsonpath.Matchs) { | ||
fmt.Printf("%s -> %v\n", (*wildcards)[0], value) | ||
for _, value := range welcome.([]interface{}) { | ||
fmt.Printf("%v\n", value) | ||
} | ||
|
||
// Output | ||
// 0 -> Hello World! | ||
// 1 -> Good Morning | ||
// Hello World! | ||
// Good Morning | ||
} | ||
|
||
func ExampleGet_filter() { | ||
|
@@ -71,7 +71,7 @@ func ExampleGet_filter() { | |
os.Exit(1) | ||
} | ||
|
||
for _, value := range welcome.(jsonpath.Matchs) { | ||
for _, value := range welcome.([]interface{}) { | ||
fmt.Println(value) | ||
} | ||
|
||
|
@@ -80,9 +80,9 @@ func ExampleGet_filter() { | |
} | ||
|
||
func Example() { | ||
builder := gval.Full(jsonpath.Language()) | ||
builder := gval.Full(jsonpath.WildcardExtension()) | ||
|
||
path, err := builder.NewEvaluable("$..[[email protected] && @.speed > 100].name") | ||
path, err := builder.NewEvaluable("{#1: $..[[email protected] && @.speed > 100].name}") | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
|
@@ -127,8 +127,8 @@ func Example() { | |
os.Exit(1) | ||
} | ||
|
||
for wildcards, device := range devices.(jsonpath.Matchs) { | ||
fmt.Printf("%s -> %v\n", (*wildcards)[1], device) | ||
for device, name := range devices.(map[string]interface{}) { | ||
fmt.Printf("%s -> %v\n", device, name) | ||
} | ||
|
||
// Unordered output: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.