File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,19 @@ All notable changes to this project will be documented in this file. It uses the
99
1010## [ v0.1.3] — Unreleased
1111
12+ ### ⚡ Improvements
13+
14+ * Added ` spec.Filter.Eval ` to allow public evaluation of a single JSON node.
15+ Used internally by ` spec.FilterSelector.Select ` .
16+ * Added ` spec.Segment.IsDescendent ` to tell wether a segments selects just
17+ from the current child node or also recursively selects from all of its
18+ descendants.
19+
1220### 📔 Notes
1321
1422* Made ` spec.SliceSelector.Bounds ` public.
1523* Made the underlying struct defining ` spec.Wildcard ` public, named it
1624 ` spec.WildcardSelector ` .
17- * Added ` spec.Filter.Eval ` to allow public evaluation of a single JSON node.
18- Used internally by ` spec.FilterSelector.Select ` .
1925
2026 [ v0.1.3 ] : https://github.com/theory/jsonpath/compare/v0.1.2...v0.1.3
2127
Original file line number Diff line number Diff line change @@ -85,3 +85,7 @@ func (s *Segment) isSingular() bool {
8585 }
8686 return s .selectors [0 ].isSingular ()
8787}
88+
89+ // IsDescendent returns true if the segment is a descendent selector that
90+ // recursively select the children of a JSON value.
91+ func (s * Segment ) IsDescendent () bool { return s .descendant }
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ func TestSegmentString(t *testing.T) {
8383 t .Parallel ()
8484 a .Equal (tc .str , tc .seg .String ())
8585 a .Equal (tc .sing , tc .seg .isSingular ())
86+ a .Equal (tc .seg .descendant , tc .seg .IsDescendent ())
8687 })
8788 }
8889}
@@ -237,6 +238,7 @@ func TestSegmentQuery(t *testing.T) {
237238 t .Parallel ()
238239 a .Equal (tc .seg .selectors , tc .seg .Selectors ())
239240 a .Equal (tc .sing , tc .seg .isSingular ())
241+ a .Equal (tc .seg .descendant , tc .seg .IsDescendent ())
240242 if tc .rand {
241243 a .ElementsMatch (tc .exp , tc .seg .Select (tc .src , nil ))
242244 } else {
@@ -433,6 +435,7 @@ func TestDescendantSegmentQuery(t *testing.T) {
433435 t .Run (tc .name , func (t * testing.T ) {
434436 t .Parallel ()
435437 a .False (tc .seg .isSingular ())
438+ a .True (tc .seg .IsDescendent ())
436439 if tc .rand {
437440 a .ElementsMatch (tc .exp , tc .seg .Select (tc .src , nil ))
438441 } else {
You can’t perform that action at this time.
0 commit comments