[Numpy-discussion] numpy array serialization with JSON

Christopher Barker Chris.Barker@noaa....
Mon Nov 10 11:58:48 CST 2008

Simon Palmer wrote:
> What, if any, header information from numarray gets put in the bytes by 
> tostring(), especially as I have n dimensions?

none, you'd have to do that separately.

> I am very likely to be deserializing into a Java Array object (or maybe 
> a double[]) and it is not clear to me how I would do that from the bytes 
> in the tostring() representation.

If you're thinking JSON, then I think you'd want text, not binary. Maybe 
you can make use of the repr()?

It wouldn't be hard to just right your own text renderer from scratch, 
unless you need C speed. Python being python, I'd tend to see what your 
Java (or Javascript) code can easily consume, then write the python code 
to generate that.

Does JSON have a representation for n-d arrays? In my little work with 
it, it looked pretty lame for arrays of number, so I'd be surprised.


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception


More information about the Numpy-discussion mailing list