Commits

Zakhar Zibarov committed cd96247

Minify JSON size

  • Participants
  • Parent commits eebb22e

Comments (0)

Files changed (2)

File jsonfield/fields.py

     def get_db_prep_value(self, value, connection=None, prepared=None):
         if value is None:
             return None
-        return json.dumps(value, default=default)
+        return json.dumps(value, default=default, separators=(',', ':'))
 
     def value_to_string(self, obj):
         value = self._get_val_from_obj(obj)

File jsonfield/tests/base.py

         field = JSONField(u"test")
         field.set_attributes_from_name("json")
         self.assertEquals(None, field.get_db_prep_value(None))
-        self.assertEquals('{"spam": "eggs"}', field.get_db_prep_value({"spam": "eggs"}))
+        self.assertEquals('{"spam":"eggs"}', field.get_db_prep_value({"spam": "eggs"}))
 
     def test_value_to_string(self):
         field = JSONField(u"test")
         obj = JSONFieldTestModel(json='''{
             "spam": "eggs"
         }''')
-        self.assertEquals(u'{"spam": "eggs"}', field.value_to_string(obj))
+        self.assertEquals(u'{"spam":"eggs"}', field.value_to_string(obj))
 
     def test_formfield(self):
         from jsonfield.forms import JSONFormField