docarray.array.mixins.io.json module

class docarray.array.mixins.io.json.JsonIOMixin[source]

Bases: object

Save/load a array into a JSON file.

save_json(file)[source]

Save array elements into a JSON file.

Comparing to save_binary(), it is human-readable but slower to save/load and the file size larger.

Parameters

file (Union[str, TextIO]) – File or filename to which the data is saved.

Return type

None

classmethod load_json(file)[source]

Load array elements from a JSON file.

Parameters

file (Union[str, TextIO]) – File or filename or a JSON string to which the data is saved.

Return type

T

Returns

a DocumentArrayLike object

to_list()[source]

Convert the object into a Python list.

Note

Array like object such as numpy.ndarray will be converted to Python list.

Return type

List

Returns

a Python list

to_json()[source]

Convert the object into a JSON string. Can be loaded via load_json().

Return type

str

Returns

a Python list