neuralib.io.json

class neuralib.io.json.JsonEncodeHandler[source]

Extend from the JSONEncoder class and handle the conversions in a default method

Usage: Add kwarg, e.g., json_dump(..., cls=JsonEncodeHandler)

default(obj)[source]

handle array/Path type

Parameters:

obj (Any)

Return type:

Any

neuralib.io.json.load_json(filepath, verbose=True, **kwargs)[source]

Load a json as dict

Parameters:
  • filepath (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – json filepath

  • verbose – verbose load

  • kwargs – additional arguments to json.load()

Returns:

Return type:

dict[str, Any]

neuralib.io.json.save_json(filepath, dict_obj, verbose=True, **kwargs)[source]

Save dict as a json file

Parameters:
  • filepath (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – json filepath

  • dict_obj (dict[str, Any]) – dictionary object

  • verbose – verbose save output

  • kwargs – additional arguments to json.dump()

Return type:

None