maci.jsondumpstr

dumps data to a string as json

dumping a string

Dumps the corresponding python data types to a string formatted as JSON.

maci.jsondumpstr -> str

Basic Example of dumping data to a string using default positional parameters

json_string = maci.jsondumpstr(data)

In this example, we simply dump data to a string formatted as json using the jsondumpstr function and pass the data as an argument to the function, and assign the returned data to a variable.

parameters & arguments

Describes all parameter functionality and accepted data types

data: dict | list | tuple | str | int | float | bool | None

First and only 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 string.

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 string. 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

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

Last updated