From dea71f728d5e39c962ed78f3d818b7f1efe7b757 Mon Sep 17 00:00:00 2001 From: tidwall Date: Fri, 12 Jul 2019 06:46:38 -0700 Subject: [PATCH] Mention nested queries --- README.md | 8 ++++---- SYNTAX.md | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 17e0423..cab0f9f 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,9 @@ The dot and wildcard characters can be escaped with '\\'. "children": ["Sara","Alex","Jack"], "fav.movie": "Deer Hunter", "friends": [ - {"first": "Dale", "last": "Murphy", "age": 44}, - {"first": "Roger", "last": "Craig", "age": 68}, - {"first": "Jane", "last": "Murphy", "age": 47} + {"first": "Dale", "last": "Murphy", "age": 44, "nets": ["ig", "fb", "tw"]}, + {"first": "Roger", "last": "Craig", "age": 68, "nets": ["fb", "tw"]}, + {"first": "Jane", "last": "Murphy", "age": 47, "nets": ["ig", "tw"]} ] } ``` @@ -95,13 +95,13 @@ matches with `#(...)#`. Queries support the `==`, `!=`, `<`, `<=`, `>`, `>=` comparison operators and the simple pattern matching `%` (like) and `!%` (not like) operators. - ``` friends.#(last=="Murphy").first >> "Dale" friends.#(last=="Murphy")#.first >> ["Dale","Jane"] friends.#(age>45)#.last >> ["Craig","Murphy"] friends.#(first%"D*").last >> "Murphy" friends.#(first!%"D*").last >> "Craig" +friends.#(nets.#(=="fb"))#.first >> ["Dale","Roger"] ``` *Please note that prior to v1.3.0, queries used the `#[...]` brackets. This was diff --git a/SYNTAX.md b/SYNTAX.md index 60af5fc..dda33af 100644 --- a/SYNTAX.md +++ b/SYNTAX.md @@ -34,9 +34,9 @@ Given this JSON "children": ["Sara","Alex","Jack"], "fav.movie": "Deer Hunter", "friends": [ - {"first": "Dale", "last": "Murphy", "age": 44}, - {"first": "Roger", "last": "Craig", "age": 68}, - {"first": "Jane", "last": "Murphy", "age": 47} + {"first": "Dale", "last": "Murphy", "age": 44, "nets": ["ig", "fb", "tw"]}, + {"first": "Roger", "last": "Craig", "age": 68, "nets": ["fb", "tw"]}, + {"first": "Jane", "last": "Murphy", "age": 47, "nets": ["ig", "tw"]} ] } ``` @@ -76,7 +76,6 @@ Special purpose characters, such as `.`, `*`, and `?` can be escaped with `\`. fav\.movie "Deer Hunter" ``` - ### Arrays The `#` character allows for digging into JSON Arrays. @@ -109,6 +108,12 @@ children.#(!%"*a*") "Alex" children.#(%"*a*")# ["Sara","Jack"] ``` +Nested queries are allowed. + +```go +friends.#(nets.#(=="fb"))#.first >> ["Dale","Roger"] +``` + *Please note that prior to v1.3.0, queries used the `#[...]` brackets. This was changed in v1.3.0 as to avoid confusion with the new [multipath](#multipaths) syntax. For backwards compatibility, `#[...]` will continue to work until the