build an info.json from KLE

This commit is contained in:
Zach White 2021-01-02 17:27:44 -08:00
parent 34446b79d7
commit 0f8b34771d
3 changed files with 124 additions and 44 deletions

View file

@ -17,6 +17,17 @@ class InfoJSONEncoder(json.JSONEncoder):
if not self.indent:
self.indent = 4
def default(self, obj):
"""Fix certain objects that don't encode.
"""
if isinstance(obj, Decimal):
if obj == int(obj):
return int(obj)
return float(obj)
return json.JSONEncoder.default(self, obj)
def encode(self, obj):
"""Encode JSON objects for QMK.
"""