Sample from the README does not work
retorquere opened this issue · 1 comments
retorquere commented
I've just copied this from the README:
README script
from compact_json import Formatter, EolStyle
formatter = Formatter()
formatter.indent_spaces = 2
formatter.max_inline_complexity = 10
formatter.json_eol_style = EolStyle.LF
# Format the JSON contents:
with open("input.json", "r") as f:
obj = json.load(f)
json_string = formatter.serialize(obj)
print(json_string)
# Create a new JSON file with formatted JSON contents:
with open("input.json", "r") as f:
obj = json.load(f)
formatter.dump(obj, output_file="output.json", newline_at_eof=True)
Minor details is that it should import json
, but even when I do that, I get
AttributeError: 'Formatter' object has no attribute 'dump'
masaccio commented
Finally updated. Thanks for the issue report.