Im trying to save a numpy array to a json but since a ndarray is not JSON serializable I am converting them to lists. My problem is that this consumes an excesive amount of RAM. Is there any other lightweight method?
1 Answer 1
You can use numpyencoder:
import numpy as np
import json
from numpyencoder import NumpyEncoder
numpy_data = np.array([0, 1, 2, 3])
print(json.dumps(numpy_data, cls=NumpyEncoder))
answered Jul 3, 2020 at 13:26
1 Comment
esantix
Shows great improvement!
lang-py