Add support for 'arraylike' objects as JSON arrays #317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
JMESPath.py is limited in that only the
dict
andlist
derived containers returned by the built-injson
library are supported in the object hierarchy due to the use ofisinstance
. A very notable arraylike instance that does not derive directly from these containers is anumpy.ndarray
which can be deserialized using the JSON-likemsgpack
library withmsgpack_numpy
.This changeset aims to add support for arraylike (
list
,tuple
andnumpy.ndarray
) containers in place of parsed JSON arrays and without adding any dependency on thenumpy
library. This is done using the documented numpy array interface protocol of which many more arraylike libraries adhere to such asxarray
,dask
,astropy
andcupy
.(
pandas.Series
is also arraylike but limited to 1D as multidimensional Series isn't an intended use case and has slicing issues)