Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87033efcae | ||
|
|
5cd723d566 | ||
|
|
62ee2064df | ||
|
|
09641abb33 |
@@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
|
||||
<p align="center">get a json value quickly</a></p>
|
||||
<p align="center">get json values quickly</a></p>
|
||||
|
||||
GJSON is a Go package that provides a [fast](#performance) and [simple](#get-a-value) way to get values from a json document.
|
||||
It has features such as [one line retrieval](#get-a-value), [dot notation paths](#path-syntax), [iteration](#iterate-through-an-object-or-array).
|
||||
|
||||
8
gjson.go
8
gjson.go
@@ -1077,7 +1077,7 @@ func queryMatches(rp *arrayPathResult, value Result) bool {
|
||||
case "=":
|
||||
return value.Num == rpvn
|
||||
case "!=":
|
||||
return value.Num == rpvn
|
||||
return value.Num != rpvn
|
||||
case "<":
|
||||
return value.Num < rpvn
|
||||
case "<=":
|
||||
@@ -1610,11 +1610,7 @@ func GetMany(json string, path ...string) []Result {
|
||||
// The return value is a Result array where the number of items
|
||||
// will be equal to the number of input paths.
|
||||
func GetManyBytes(json []byte, path ...string) []Result {
|
||||
res := make([]Result, len(path))
|
||||
for i, path := range path {
|
||||
res[i] = GetBytes(json, path)
|
||||
}
|
||||
return res
|
||||
return GetMany(string(json), path...)
|
||||
}
|
||||
|
||||
var fieldsmu sync.RWMutex
|
||||
|
||||
@@ -1275,7 +1275,6 @@ func randomObjectOrArray(keys []string, prefix string, array bool, depth int) (s
|
||||
}
|
||||
|
||||
func randomJSON() (json string, keys []string) {
|
||||
//rand.Seed(time.Now().UnixNano())
|
||||
return randomObjectOrArray(nil, "", false, 0)
|
||||
}
|
||||
|
||||
@@ -1289,3 +1288,10 @@ func TestIssue55(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestIssue58(t *testing.T) {
|
||||
json := `{"data":[{"uid": 1},{"uid": 2}]}`
|
||||
res := Get(json, `data.#[uid!=1]`).Raw
|
||||
if res != `{"uid": 2}` {
|
||||
t.Fatalf("expected '%v', got '%v'", `{"uid": 1}`, res)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user