JSONIO

class upsilonconf.io.JSONIO(indent: int = 2, sort_keys: bool = False)[source]

IO for reading/writing JSON files.

Added in version 0.5.0.

Parameters:
indentint, optional

The number of spaces to use for indentation in the output file.

sort_keysbool, optional

Whether keys should be sorted before writing to the output file.

property extensions

Collection of extensions that are supported by this IO.

read_from(stream)[source]

Read configuration from a file-like object.

Parameters:
streamTextIO

Readable character stream (file-like object).

Returns:
configdict

A dictionary representing the configuration in the stream.

Raises:
TypeError

If the implementation does not support reading from a stream.

write_to(stream, conf)[source]

Write configuration to a file-like object.

Parameters:
streamTextIO

Writeable character stream (file-like object).

confMapping

A dictionary representing the configuration to be written.

Raises:
TypeError

If the implementation does not support writing to a stream.