adriank / ObjectPath

The agile query language for semi-structured data
http://objectpath.org
MIT License
380 stars 93 forks source link

"key in $" no support for existence on root level #102

Closed gcemaj closed 3 years ago

gcemaj commented 3 years ago
a_dict = {
   "a" : 1,
   "b": {
       "c": 1,
       "d": None
    }
}

tree =  objectpath.Tree(a_dict)

tree.execute("c in $.b") # -> True
tree.execute("d in $.b") # -> True
tree.execute("e in $.b") # -> False
tree.execute("e in $") # -> Error

I cannot query existence of a top level key, only if it is nested

adriank commented 3 years ago

tree.execute("e in $.*") # -> False

Greetings, Adrian Kalbarczyk

https://kalbarczyk.co | https://devyard.io

On Tue, Feb 2, 2021 at 9:03 PM gcemaj notifications@github.com wrote:

a_dict = { "a" : 1, "b": { "c": 1, "d": None } }

tree = objectpath.Tree(a_dict)

tree.execute("c in $.b") # -> True tree.execute("d in $.b") # -> True tree.execute("e in $.b") # -> False tree.execute("e in $") # -> Error

I cannot query existence of a top level key, only if it is nested

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adriank/ObjectPath/issues/102, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABLE4QM7ZOUKYPFVS2GWFTS5BLA7ANCNFSM4W7PBBUA .

gcemaj commented 3 years ago

Thanks!