Skip to content

Commit 2f47af1

Browse files
committed
Implement __str__ for the current key identifier
1 parent 592794e commit 2f47af1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

jsonpath/filter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,9 @@ def __init__(self) -> None:
668668
super().__init__()
669669
self.volatile = True
670670

671+
def __str__(self) -> str:
672+
return "#"
673+
671674
def __eq__(self, other: object) -> bool:
672675
return isinstance(other, CurrentKey)
673676

tests/test_parse.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ class Case:
170170
path="$.some.~",
171171
want="$['some'][~]",
172172
),
173+
Case(
174+
description="current key identifier",
175+
path="$[?# > 2]",
176+
want="$[?# > 2]",
177+
),
173178
Case(
174179
description="comparison to single quoted string literal with escape",
175180
path="$[[email protected] == 'ba\\'r']",

0 commit comments

Comments
 (0)