Order JSON freeze fields deterministically

To avoid commits like [this
one](f0599f87bc)
on Python 3
This commit is contained in:
Paul M Furley 2016-11-21 07:30:43 +00:00
parent 6fc8bfed51
commit 866713f110

View File

@ -1,6 +1,6 @@
import json
from datetime import datetime, date
from collections import defaultdict
from collections import defaultdict, OrderedDict
from decimal import Decimal
from six import PY3
@ -29,10 +29,10 @@ class JSONSerializer(Serializer):
if self.mode == 'item':
result = result[0]
if self.export.get_bool('wrap', True):
result = {
'count': len(result),
'results': result
}
result = OrderedDict([
('count', len(result)),
('results', result),
])
meta = self.export.get('meta', {})
if meta is not None:
result['meta'] = meta