diff --git a/gjson.go b/gjson.go index cd8dae6..0e6f3f0 100644 --- a/gjson.go +++ b/gjson.go @@ -647,6 +647,7 @@ func parseArrayPath(path string) (r arrayPathResult) { for ; i < len(path); i++ { if path[i] <= ' ' || path[i] == '=' || path[i] == '<' || path[i] == '>' || + path[i] == '%' || path[i] == ']' { break } @@ -997,6 +998,8 @@ func queryMatches(rp *arrayPathResult, value Result) bool { return value.Str > rpv case ">=": return value.Str >= rpv + case "%": + return match.Match(value.Str, rpv) } case Number: rpvn, _ := strconv.ParseFloat(rpv, 64) diff --git a/gjson_test.go b/gjson_test.go index be61517..615ad2c 100644 --- a/gjson_test.go +++ b/gjson_test.go @@ -205,6 +205,10 @@ func TestBasic(t *testing.T) { t.Fatalf("expected %v, got %v", "1002.3", mtok.String()) } + mtok = get(basicJSON, `loggy.programmers.#[firstName % "Bre*"].email`) + if mtok.String() != "aaaa" { + t.Fatalf("expected %v, got %v", "aaaa", mtok.String()) + } mtok = get(basicJSON, `loggy.programmers.#[firstName == "Brett"].email`) if mtok.String() != "aaaa" { t.Fatalf("expected %v, got %v", "aaaa", mtok.String())