Avoid trailing whitespace in the JSON output

The default separators used in the Python JSON library's dump() write
output with trailing whitespace. Use custom separators to avoid that, as
described in the documentation:

  http://docs.python.org/2/library/json.html
This commit is contained in:
Mike Gerber
2014-03-28 15:43:11 +01:00
parent 5df2ff66e0
commit 5ef339d7a5
+1 -1
View File
@@ -314,7 +314,7 @@ class JsonContainer(AnnotationContainer):
"""
# TODO make all image filenames relative to the label file
f = open(fname, "w")
json.dump(annotations, f, indent=4, sort_keys=True)
json.dump(annotations, f, indent=4, separators=(',', ': '), sort_keys=True)
class YamlContainer(AnnotationContainer):