diff --git a/check50.py b/check50.py index 0927033c..0a187bef 100755 --- a/check50.py +++ b/check50.py @@ -248,7 +248,7 @@ def print_json(results): pass output.append(obj) - print(json.dumps(output)) + print(json.dumps(output, cls=Encoder)) def import_checks(identifier): @@ -426,6 +426,15 @@ def wrapper(self): return decorator +class Encoder(json.JSONEncoder): + """Custom class for JSON encoding.""" + + def default(self, o): + if o == EOF: + return "EOF" + return o.__dict__ + + class File(object): """Generic class to represent file in check directory.""" diff --git a/setup.py b/setup.py index 2b1ac814..f6845cd7 100644 --- a/setup.py +++ b/setup.py @@ -60,5 +60,5 @@ class CustomInstall(install): "console_scripts": ["check50=check50:main"] }, url="https://github.com/cs50/check50", - version="2.1.2" + version="2.1.3" )