Ujson cannot encode numpy array

numpy array

x = np.array([1,2,3,4])

      

ujson.encode

ujson.encode(x, ensure_ascii=False, double_precision=-1)

      

gives me error

OverflowError: Maximum recursion level reached

      

version information

ujson 1.33
python 3.4.3

      

It looks like ujson cannot encode numpy array and gives confusing error message.

By the way, where can I find the ujson documentation. THH

+3


source to share


1 answer


Make sure to convert any numpy arrays to regular lists before jsonification. Hence,

ujson.encode(x.tolist())

      

should work (Python 3.5.3; ujson 1.35).



Ujson documentation: https://github.com/esnme/ultrajson

Btw there is an issue for what you described.

+1


source







All Articles