kedro.io.JSONLocalDataSet

class kedro.io.JSONLocalDataSet(filepath, load_args=None, save_args=None, version=None)[source]

JSONLocalDataSet encodes data as json and saves it to a local file or reads in and decodes an existing json file. The encoding/decoding functionality is provided by Python’s json library.

Example:

from kedro.io import JSONLocalDataSet
my_dict = {
    'a_string': 'Hello, World!',
    'a_list': [1, 2, 3]
}
data_set = JSONLocalDataSet(filepath="test.json")
data_set.save(my_dict)
reloaded = data_set.load()
assert my_dict == reloaded
__init__(filepath, load_args=None, save_args=None, version=None)[source]

Creates a new instance of JSONLocalDataSet pointing to a concrete filepath.

Parameters:
  • filepath (str) – path to a local json file.
  • load_args (Optional[Dict[str, Any]]) – Arguments passed on to `json.load. See https://docs.python.org/3/library/json.html for details. All defaults are preserved.
  • save_args (Optional[Dict[str, Any]]) – Arguments passed on to `json.dump. See https://docs.python.org/3/library/json.html for details. All defaults are preserved.
  • version (Optional[Version]) – If specified, should be an instance of kedro.io.core.Version. If its load attribute is None, the latest version will be loaded. If its save attribute is None, save version will be autogenerated.
Return type:

None

Methods

__init__(filepath[, load_args, save_args, …]) Creates a new instance of JSONLocalDataSet pointing to a concrete filepath.
exists() Checks whether a data set’s output already exists by calling the provided _exists() method.
from_config(name, config[, load_version, …]) Create a data set instance using the configuration provided.
load() Loads data by delegation to the provided load method.
save(data) Saves data by delegation to the provided save method.