to_arrays_and_json#
- seli.to_arrays_and_json(obj: None | bool | int | float | str | type | Array | ShapeDtypeStruct | list | dict | Module | Any) tuple[list[Array], str][source]#
Serialize a nested structure of modules and arrays and other containers to a JSON string and a list of arrays.
This works by traversing the nested structure and replacing arrays with ArrayPlaceholder objects. The ArrayPlaceholder objects are then replaced with the actual arrays during deserialization.
Then the Modules are replaced with dictionaries containing the module class and all its attributes. The class is stored as “__class__” in the dictionary and turned into a string using the registry.
- Parameters:
obj (NodeType) – The nested structure to serialize.
- Returns:
A tuple containing a list of arrays and a JSON string.
- Return type:
tuple[list[jax.Array], str]