Use compact separators to dump json
issue6373 review33991002
This commit is contained in:
1 parent
220d35fb7f
commit
e7ff9ee619
6 files changed
+9
-7
No files matched your search
+2
-1
@@ -1115,7 +1115,8 @@ class ModelData(ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def dump_values(cls, values):
|
||||
return json.dumps(sorted(values.iteritems()), cls=JSONEncoder)
|
||||
return json.dumps(
|
||||
sorted(values.iteritems()), cls=JSONEncoder, separators=(',', ':'))
|
||||
|
||||
@classmethod
|
||||
def load_values(cls, values):
|
||||
|
||||
@@ -357,7 +357,7 @@ class ViewTreeState(ModelSQL, ModelView):
|
||||
@classmethod
|
||||
def set(cls, model, domain, child_name, nodes, selected_nodes):
|
||||
# Normalize the json domain
|
||||
domain = json.dumps(json.loads(domain))
|
||||
domain = json.dumps(json.loads(domain), separators=(',', ':'))
|
||||
current_user = Transaction().user
|
||||
records = cls.search([
|
||||
('user', '=', current_user),
|
||||
@@ -378,7 +378,7 @@ class ViewTreeState(ModelSQL, ModelView):
|
||||
@classmethod
|
||||
def get(cls, model, domain, child_name):
|
||||
# Normalize the json domain
|
||||
domain = json.dumps(json.loads(domain))
|
||||
domain = json.dumps(json.loads(domain), separators=(',', ':'))
|
||||
current_user = Transaction().user
|
||||
try:
|
||||
expanded_info, = cls.search([
|
||||
|
||||
@@ -60,7 +60,7 @@ class DictSchemaMixin(object):
|
||||
db_selection = self.selection or ''
|
||||
selection = [[w.strip() for w in v.split(':', 1)]
|
||||
for v in db_selection.splitlines() if v]
|
||||
return json.dumps(selection)
|
||||
return json.dumps(selection, separators=(',', ':'))
|
||||
|
||||
@classmethod
|
||||
def get_keys(cls, records):
|
||||
|
||||
@@ -37,7 +37,7 @@ class Dict(Field):
|
||||
if value is None:
|
||||
return None
|
||||
assert isinstance(value, dict)
|
||||
return json.dumps(value, cls=JSONEncoder)
|
||||
return json.dumps(value, cls=JSONEncoder, separators=(',', ':'))
|
||||
|
||||
def sql_type(self):
|
||||
return SQLType('TEXT', 'TEXT')
|
||||
|
||||
@@ -156,5 +156,6 @@ class JSONProtocol:
|
||||
if isinstance(data, Exception):
|
||||
return InternalServerError(data)
|
||||
response = data
|
||||
return Response(json.dumps(response, cls=JSONEncoder),
|
||||
return Response(json.dumps(
|
||||
response, cls=JSONEncoder, separators=(',', ':')),
|
||||
content_type='application/json')
|
||||
@@ -341,7 +341,7 @@ class Wizard(WarningErrorMixin, URLMixin, PoolBase):
|
||||
if isinstance(state, StateView):
|
||||
data[state_name] = getattr(self, state_name)._default_values
|
||||
session = Session(self._session_id)
|
||||
data = json.dumps(data, cls=JSONEncoder)
|
||||
data = json.dumps(data, cls=JSONEncoder, separators=(',', ':'))
|
||||
if data != session.data.encode('utf-8'):
|
||||
Session.write([session], {
|
||||
'data': data,
|
||||
|
||||
Reference in new issue
Block a user