Skip to content

json

dandy.recorder.renderer.json

JsonRecordingRenderer

Bases: BaseRecordingRenderer

name = 'json' class-attribute instance-attribute

file_extension = 'json' class-attribute instance-attribute

to_file

Source code in dandy/recorder/renderer/json.py
def to_file(
        self,
        path: Path | str,
):
    Path(path).mkdir(parents=True, exist_ok=True)

    with open(
            Path(path, f'{self.recording.name}{RECORDING_POSTFIX_NAME}.json'),
            'w',
            encoding='utf-8'
    ) as new_file:
        new_file.write(self.to_str())

to_str

Source code in dandy/recorder/renderer/json.py
def to_str(self) -> str:
    return self._render_json_to_str()