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

View File

@ -5,6 +5,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"log"
"math/rand"
"reflect"
"strconv"
@ -1434,9 +1435,16 @@ func TestArrayValues(t *testing.T) {
}
func TestEsonRegexp(t *testing.T) {
mtok := get(`{"data": [ {"dat": "123\"", "next": [{"a": "\"32"}, {"a": "32"}]}, {"dat": "234"} ] }`, `data.#[dat % "3\""].next.#[a % "\"32"]#.a`)
func TestRegexp(t *testing.T) {
mtok := get(`{"data": [ {"dat": "123\"", "next": [{"a": "\"32"}, {"a": "32"}]}, {"dat": "234"} ] }`, `data.#[dat ~ "3\""].next.#[a ~ @\"32@]#.a`)
if mtok.String() != `["\"32"]` {
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("")
}