Skip to content

Commit 287cece

Browse files
committed
Fix keys with Boolean names
1 parent dcda7ed commit 287cece

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

jsonpath_ng/ext/parser.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class ExtendedJsonPathLexer(lexer.JsonPathLexer):
3030

3131
t_FILTER_OP = r'=~|==?|<=|>=|!=|<|>'
3232

33-
def t_BOOL(self, t):
34-
r'true|false'
35-
t.value = True if t.value == 'true' else False
36-
return t
37-
3833
def t_SORT_DIRECTION(self, t):
3934
r',?\s*(/|\\)'
4035
t.value = t.value[-1]
@@ -47,6 +42,11 @@ def t_ID(self, t):
4742
t.type = self.reserved_words.get(t.value, 'ID')
4843
return t
4944

45+
def t_BOOL(self, t):
46+
r'true|false'
47+
t.value = True if t.value == 'true' else False
48+
return t
49+
5050
def t_FLOAT(self, t):
5151
r'-?\d+\.\d+'
5252
t.value = float(t.value)

tests/test_parser.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
("foo", Fields("foo")),
1414
("*", Fields("*")),
1515
("1", Fields("1")),
16+
("trueName", Fields("trueName")),
1617
("baz,bizzle", Fields("baz", "bizzle")),
1718
("[1]", Index(1)),
1819
("[1:]", Slice(start=1)),

0 commit comments

Comments
 (0)