Use JSON canonical form for Dict value

It allows to make equality comparison.

issue7013
review39041002
This commit is contained in:
Cédric Krier
2017-12-20 19:26:44 +01:00
parent a2269d5a38
commit 8cfd0eb692
2 changed files with 4 additions and 1 deletions
+1
View File
@@ -1,3 +1,4 @@
* Use JSON canonical form for Dict value
* Remove rules on user
* Add monetary formatting to language
* Add exceptional parent language
+3 -1
View File
@@ -37,7 +37,9 @@ class Dict(Field):
if value is None:
return None
assert isinstance(value, dict)
return json.dumps(value, cls=JSONEncoder, separators=(',', ':'))
# Use canonical form
return json.dumps(
value, cls=JSONEncoder, separators=(',', ':'), sort_keys=True)
def translated(self, name=None, type_='values'):
"Return a descriptor for the translated value of the field"