Skip to content

Commit

Permalink
Find selectors inside nested lists for recursive descent
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgmer committed Dec 12, 2016
1 parent 6ea1589 commit 85c95fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/json_path/walker.clj
Expand Up @@ -24,7 +24,7 @@
(defn obj-vals [obj]
(cond
(seq? obj) obj
(map? obj) (filter map? (vals obj))
(map? obj) (filter #(or (map? %) (sequential? %)) (vals obj))
:else []))

(defn obj-aggregator [obj]
Expand Down
5 changes: 4 additions & 1 deletion test/json_path/test/walker_test.clj
Expand Up @@ -27,7 +27,10 @@
(walk-path [[:root]] {:root ...root..., :current ...obj...}) => ...root...
(walk-path [[:root] [:child] [:key "foo"]] {:root {:foo "bar"}}) => "bar"
(walk-path [[:all-children]] {:current {:foo "bar" :baz {:qux "zoo"}}}) => [{:foo "bar" :baz {:qux "zoo"}},
{:qux "zoo"}])
{:qux "zoo"}]
(walk-path [[:all-children] [:key "bar"]]
{:current {:foo [{:bar "wrong"}
{:bar "baz"}]}}) => ["wrong" "baz"])

(fact
(walk-selector [:index "1"] {:current ["foo", "bar", "baz"]}) => "bar"
Expand Down

0 comments on commit 85c95fe

Please sign in to comment.