orjson icon indicating copy to clipboard operation
orjson copied to clipboard

de-searailize numpy having back a numpy array?

Open vlavorini opened this issue 1 year ago • 0 comments
trafficstars

Hello,

I see that de-serializing a serialized Numpy array gives back a list.

Is there a way to have back a Numpy array, apart from calling an explicit conversion afterwards?

thank you.

Code example:

import numpy as np
import orjson

asd = {"arr": np.array([1, 2, 4.5]),
       "text": "bla"}
data = orjson.dumps(asd, option=orjson.OPT_NAIVE_UTC | orjson.OPT_SERIALIZE_NUMPY)

data_des = orjson.loads(data)

print (type(data_des['arr']))  # this prints (<class 'list'>)

vlavorini avatar Aug 21 '24 09:08 vlavorini