class ray.data.datasource.JSONDatasource[source]#

Bases: ray.data.datasource.file_based_datasource.FileBasedDatasource

JSON datasource, for reading and writing JSON files.


>>> import ray
>>> from ray.data.datasource import JSONDatasource
>>> source = JSONDatasource() 
>>> ray.data.read_datasource( 
...     source, paths="/path/to/dir").take()
[{"a": 1, "b": "foo"}, ...]

PublicAPI: This API is stable across Ray releases.



do_write(blocks, metadata, ray_remote_args, ...)

Launch Ray tasks for writing blocks out to the datasource.


Return a human-readable name for this datasource.

on_write_complete(write_results, **kwargs)

Callback for when a write job completes.

on_write_failed(write_results, error, **kwargs)

Callback for when a write job fails.

prepare_read(parallelism, **read_args)

Deprecated: Please implement create_reader() instead.

write(blocks, ctx, path, dataset_uuid[, ...])

Write blocks for a file-based datasource.