h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
572 stars 85 forks source link

Support non-subscriptable objects #76

Closed sourcesimian closed 11 months ago

sourcesimian commented 3 years ago

It would be great if this library could be used to access and modify Kubernetes objects. Using hasattr(), getattr() and setattr() is more generic than field in data, data[field] and data[field] = value.

michaelmior commented 11 months ago

This seems to cause many of the tests to fail. I wouldn't say hasattr et al. "more generic." Using these means that code won't work for dictionaries anymore. I'm going to close this for now, but if you're still interested, it's probably possible to make this work for both cases.

>>> getattr({"foo": 3}, "foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'dict' object has no attribute 'foo'