Closed pkerpedjiev closed 8 years ago
$ needs to be postponed by . or .. and then attribute name or wildcard.
list(tree.execute('$.*[@.x < 2]')) should work. :)
Thanks for the quick response! It does indeed work.
But shouldn't the version I posted also work?
If $.data[@.x < 2]
refers to all entries in $.data
where x < 2, then shouldn't $[@.x < 2]
logically refer to all entries in $
where x < 2?
For me $[@
looks like brainfuck. :)
If you like to change this behavior go here: https://github.com/adriank/ObjectPath/blob/master/objectpath/core/parser.py#L274 and comment lines: 274, 276-278. Namespaces doesn't work ATM so nothing will break.
Consider the correctly working code below. It simply selects the elements where
x<2
.Now if we remove
data
and make the list the root node, it doesn't work:Is there a reason why this is so? Should it be so? Wouldn't it make conceptual sense to be able to do the same filters on the root node as on child nodes?