[Numpy-discussion] numpy array serialization with JSON

Christopher Barker Chris.Barker at noaa.gov
Mon Nov 10 12:58:48 EST 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.

-Chris

-- 
Christopher Barker, Ph.D.
Oceanographer

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

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list