adriank / ObjectPath

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

Added `values` function #71

Closed u8sand closed 5 years ago

u8sand commented 5 years ago

Our structure uses a dictionary instead of a list but we only know about the values, not the keys. I was originally considering overriding * to also work with dictionaries (defaulting to converting them to values), but found that just adding a values function offered less ambiguous functionality.

A test was added demonstrating how this might be useful. We are crawling OpenAPI specifications and this is a situation which arrises.

u8sand commented 5 years ago

FYI, I ended up chaining map--this might have side-effects but it still passes all tests so in my opinion might be a nice option (handling these types of weird cases automatically as noted in the test). Else we could also add a new function chain to do this.

adriank commented 5 years ago

Thanks for the PR. We'll see if chain would break anyone's code, but I don't see cons ATM.