Skip to content

Commit a89da7f

Browse files
committed
Supports string slices
1 parent 5bd9fec commit a89da7f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

jmespath/visitor.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ def visit_pipe(self, node, value):
277277

278278
def visit_projection(self, node, value):
279279
base = self.visit(node['children'][0], value)
280+
281+
allow_string = False
282+
first_child = node['children'][0]
283+
if first_child['type'] == 'index_expression':
284+
nested_children = first_child['children']
285+
if len(nested_children) > 1 and nested_children[1]['type'] == 'slice':
286+
allow_string = True
287+
288+
if isinstance(base, string_type) and allow_string:
289+
return base
290+
280291
if not isinstance(base, list):
281292
return None
282293
collected = []

0 commit comments

Comments
 (0)