fix: src code error.

This commit is contained in:
eson 2018-12-24 20:03:07 +08:00
parent 862cbc6b80
commit ab583cb85c
2 changed files with 14 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"errors" "errors"
"log"
"reflect" "reflect"
"regexp" "regexp"
"strconv" "strconv"
@ -780,9 +781,10 @@ func parseArrayPath(path string) (r arrayPathResult) {
break break
} }
} }
s = i + 1 s = i
if r.query.op == "~" { if r.query.op == "~" {
s = i + 1
pair := path[i] pair := path[i]
i++ i++
GETREGEXPSTR: GETREGEXPSTR:
@ -1134,6 +1136,7 @@ func queryMatches(rp *arrayPathResult, value Result) bool {
case String: case String:
switch rp.query.op { switch rp.query.op {
case "=": case "=":
log.Println(rpv, value.Str)
return value.Str == rpv return value.Str == rpv
case "!=": case "!=":
return value.Str != rpv return value.Str != rpv

View File

@ -5,6 +5,7 @@ import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"fmt" "fmt"
"log"
"math/rand" "math/rand"
"reflect" "reflect"
"strconv" "strconv"
@ -1434,9 +1435,16 @@ func TestArrayValues(t *testing.T) {
} }
func TestEsonRegexp(t *testing.T) { func TestRegexp(t *testing.T) {
mtok := get(`{"data": [ {"dat": "123\"", "next": [{"a": "\"32"}, {"a": "32"}]}, {"dat": "234"} ] }`, `data.#[dat % "3\""].next.#[a % "\"32"]#.a`) mtok := get(`{"data": [ {"dat": "123\"", "next": [{"a": "\"32"}, {"a": "32"}]}, {"dat": "234"} ] }`, `data.#[dat ~ "3\""].next.#[a ~ @\"32@]#.a`)
if mtok.String() != `["\"32"]` { if mtok.String() != `["\"32"]` {
t.Fatalf("expected %v, got %v", `"32`, mtok.String()) t.Fatalf("expected %v, got %v", `"32`, mtok.String())
} }
} }
func TestChinese(t *testing.T) {
js := `{"data": [{"f":"广告"}, {"f": "广告"}]}`
mtok := get(js, `data.#[f~"广告"]#`)
log.Println(mtok.String())
t.Error("")
}