Skip to content

Commit

Permalink
learned to handle values.
Browse files Browse the repository at this point in the history
  • Loading branch information
springcomp committed Oct 28, 2022
1 parent bbe7300 commit 79e703a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions jmespath/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def visit_subexpression(self, node, value):
result = value
for node in node['children']:
result = self.visit(node, result)
if (result is None):
return None
return result

def visit_field(self, node, value):
Expand Down Expand Up @@ -228,16 +230,12 @@ def visit_literal(self, node, value):
return node['value']

def visit_multi_select_dict(self, node, value):
if value is None:
return None
collected = self._dict_cls()
for child in node['children']:
collected[child['value']] = self.visit(child, value)
return collected

def visit_multi_select_list(self, node, value):
if value is None:
return None
collected = []
for child in node['children']:
collected.append(self.visit(child, value))
Expand Down
4 changes: 4 additions & 0 deletions tests/compliance/pipe.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@
{
"expression": "foo[*].bar[*] | [0][0]",
"result": {"baz": "one"}
},
{
"expression": "`null`|[@]",
"result": [ null ]
}
]
}]

0 comments on commit 79e703a

Please sign in to comment.