Dumps the corresponding python data types to a file formatted as JSON. Nothing is returned. Creates a new or overwrites an existing file by default (See append parameter to change mode).
Basic Example of dumping data to a file using default positional parameters
maci.jsondump('mydata.json', data)
In this example, we simply dump data to a file using the jsondump function and pass a string of the filepath to the file as the first argument to the function, then pass the data as the second argument to the function.
parameters & arguments
Describes all parameter functionality and accepted data types
filename: str | Path
First required positional argument. Accepts strings and Path objects
Use this parameter to point to your filepath
data: dict | list | tuple | str | int | float | bool | None
Second required positional argument. Accepts dictionaries, lists, tuples, strings, integers, floats, booleans, and None
Use this parameter to pass in the data you want to dump to a file.
Use this parameter to enable appending mode to write by appending data to the file. A new file will be created if the filename does not exist. Default is disabled which writes new or overwrites a file.
indent_level: int
Optional parameter. Accepts integers. Default = 4
Use this parameter to change the indentation level for structured data (lists, dicts, tuples, sets) written to the file. Indentation will be applied to nested data as well.
This parameter sets the true underlying indent level for the json library. 1 level = 1 space
encoding: str | None
Optional parameter. Accepts strings or None. Default = None
Use this parameter to dump the data with the desired codec of the data if needed. The default uses the default of python, so you don't have to use this, but you can if the data needs to be written with a specific codec.
This function uses the native json library shipped with the python standard library for its underlying functionality. For more information on the json library, visit: https://docs.python.org/3/library/json.html