4 Commits

Author SHA1 Message Date
Josh Baker
87033efcae array query mismatch, fixes #58 2018-01-23 05:45:05 -07:00
Josh Baker
5cd723d566 simplify getmanybytes 2017-12-22 07:19:48 -07:00
Josh Baker
62ee2064df remove commented line 2017-12-22 07:17:19 -07:00
Josh Baker
09641abb33 update tagline 2017-12-22 07:16:29 -07:00
3 changed files with 10 additions and 8 deletions

View File

@@ -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).

View File

@@ -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

View File

@@ -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)
}
}