Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'arraylike' objects as JSON arrays #317

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

calgray
Copy link

@calgray calgray commented Sep 18, 2023

JMESPath.py is limited in that only the dict and list derived containers returned by the built-in json library are supported in the object hierarchy due to the use of isinstance. A very notable arraylike instance that does not derive directly from these containers is a numpy.ndarray which can be deserialized using the JSON-like msgpack library with msgpack_numpy.

This changeset aims to add support for arraylike (list, tuple and numpy.ndarray) containers in place of parsed JSON arrays and without adding any dependency on the numpy library. This is done using the documented numpy array interface protocol of which many more arraylike libraries adhere to such as xarray, dask, astropy and cupy.

(pandas.Series is also arraylike but limited to 1D as multidimensional Series isn't an intended use case and has slicing issues)

@calgray calgray changed the title Add support 'arraylike' objects as JSON arrays Add support for 'arraylike' objects as JSON arrays Sep 18, 2023
@calgray calgray marked this pull request as ready for review September 18, 2023 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant