Serialize NDArray to JSON (Normal Style)
mainBy default, numpydantic serializes arrays to JSON using the 'Normal Style', which represents n-dimensional arrays as standard JSON lists-of-lists.
Warning: This method is not suitable for large arrays as it dumps the entire content into the JSON string. Additionally, all dtype information is lost, and numbers are parsed as standard Python int or float types. When re-validated, these arrays will default to being handled by the NumpyInterface.
from pydantic import BaseModel
from numpydantic import NDArray
import numpy as np
class MyModel(BaseModel):
array: NDArray
model = MyModel(array=np.array([[1, 2], [3, 4]]))
json_string = model.model_dump_json()