Skip to content

Commit

Permalink
DOC: how-to-io.rst: document solution for NumPy JSON serialization
Browse files Browse the repository at this point in the history
Users have reported that NumPy types are not JSON serializable. This is documented, but no solution is recommended. This PR suggests trying a custom NumPy JSON encoder, several of which are easily found online. Whether NumPy should provide a solution as part of the package remains an open feature request.

[skip actions] [skip azp] [skip cirrus]
  • Loading branch information
mdhaber committed Oct 14, 2023
1 parent c294f1a commit 8d10d5d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/source/user/how-to-io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,10 @@ NetCDF (see :ref:`how-to-io-large-arrays`).
Write or read a JSON file
=========================

NumPy arrays are **not** directly
NumPy arrays and most NumPy scalars are **not** directly
`JSON serializable <https://github.com/numpy/numpy/issues/12481>`_.
Instead, use a custom `json.JSONEncoder` for NumPy types, which can
be found using your favorite search engine.


.. _how-to-io-pickle-file:
Expand Down

0 comments on commit 8d10d5d

Please sign in to comment.