adriank / ObjectPath

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

** in object name #56

Closed donpython closed 6 years ago

donpython commented 6 years ago

Is there a way to find object with name of structure "name" / "**name"? I've tried this by executing $.."**name" and many other combinations on Tree Object but it didn't succeed..

There's such adnotation on documentation page:

Names can be written without quotes, but in that case they cannot start with an operator. ObjectPath raises an exception if name is not valid.

so as far as I understood it shall work with name (if between quotes)... If any character is applied before "*" (like " *name" or " %name") it works.

Thanks and hope there's a quick solution for this problem. ;)

adriank commented 6 years ago

Try $..['**name'].

Anyway seems to be a bug. Could you please create a test case that should work but fails and PR it?

donpython commented 6 years ago

Unfortunately it raises SyntaxError

SyntaxError: Expected an attribute name.

I'll create test case when I have time, thanks.

adriank commented 6 years ago

Sorry, I meant $..*['**name']. :)

mxmader commented 6 years ago

the above comment solved a similar problem for me (picking out vales of $ref in an OpenAPI schema expressed in native Python)