def write_json(_config: Config, df: DF, output: IO, **kwargs) -> None: """Write a memory usage data frame as json.""" orient = kwargs.get('method', 'records') # .removeprefix('json_') in 3.9 if orient.startswith('json_'): orient = orient[5:] df.to_json(output, orient=orient)
def write_json(config: Config, frames: DFs, output: OutputOption, method: str) -> None: """Write a group of memory usage data frames as json.""" orient = method[5:] with open_output(config, output) as out: sep = '[' for df in frames.values(): print(sep, file=out) sep = ',' df.to_json(out, orient=orient) print(']', file=out)