JsonFormatter

class dictIO.formatter.JsonFormatter

Bases: Formatter

Formatter to serialize a dict into a string in JSON dictionary format.

__init__() None

Define default configuration for JsonFormatter.

Methods

__init__()

Define default configuration for JsonFormatter.

add_double_quotes(arg)

Add double quotes to a string.

add_single_quotes(arg)

Add single quotes to a string.

format_bool(arg)

Format a boolean.

format_empty_string(arg)

Format an empty string.

format_expression_string(arg)

Format an expression.

format_float(arg)

Format a floating point number.

format_int(arg)

Format an integer.

format_key(arg)

Format a key.

format_multi_word_string(arg)

Format a multi word string.

format_none()

Format None value.

format_reference_string(arg)

Format a reference.

format_single_word_string(arg)

Format a single word string.

format_string(arg)

Format a string.

format_string_with_nested_string(arg)

Format a string that contains a nested string.

format_value(arg)

Format a single value.

format_values(arg)

Format multiple values.

get_formatter([target_file])

Return a Formatter instance matching the type of the target file to be formatted (factory method).

insert_includes(s_dict, s)

Insert back all include directives.

to_string(arg)

Create a string representation of the passed in dict in JSON dictionary format.

insert_includes(s_dict: SDict[K, V], s: str) str

Insert back all include directives.

to_string(arg: MutableMapping[K, V]) str

Create a string representation of the passed in dict in JSON dictionary format.

Parameters:

arg (MutableMapping[K, V]) – dict to be formatted

Returns:

string representation of the dict in JSON dictionary format

Return type:

str