Serialize/deserialize ndarrays to and from JSON