Skip to content

Commit c4f224c

Browse files
committed
Return flattened seq for nested matches
1 parent 7332dc8 commit c4f224c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/json_path/walker.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
(defn map# [func obj]
1818
(if (seq? obj)
19-
(map (partial map# func) obj)
19+
(->> obj
20+
(flatten)
21+
(map (partial map# func)))
2022
(func obj)))
2123

2224
(defn- select-all [current-context]

test/json_path/test/json_path_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{:id 45, :foo [{:id 12, :text "bar"},
2727
{:id 45, :text "hello"}]}) => ["hello"]
2828
(at-path "$.foo[*].bar[*].baz"
29-
{:foo [{:bar [{:baz "hello"}]}]}) => [["hello"]])
29+
{:foo [{:bar [{:baz "hello"}]}]}) => ["hello"])
3030

3131
(facts
3232
(-> (query "$.hello"

0 commit comments

Comments
 (0)