summaryrefslogtreecommitdiff
path: root/lib/python/qmk/json_encoders.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/json_encoders.py')
-rwxr-xr-xlib/python/qmk/json_encoders.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/python/qmk/json_encoders.py b/lib/python/qmk/json_encoders.py
index 1e90f6a288..0e4ad1d220 100755
--- a/lib/python/qmk/json_encoders.py
+++ b/lib/python/qmk/json_encoders.py
@@ -217,3 +217,21 @@ class KeymapJSONEncoder(QMKJSONEncoder):
return '50' + str(key)
return key
+
+
+class UserspaceJSONEncoder(QMKJSONEncoder):
+ """Custom encoder to make userspace qmk.json's a little nicer to work with.
+ """
+ def sort_dict(self, item):
+ """Sorts the hashes in a nice way.
+ """
+ key = item[0]
+
+ if self.indentation_level == 1:
+ if key == 'userspace_version':
+ return '00userspace_version'
+
+ if key == 'build_targets':
+ return '01build_targets'
+
+ return key