[damned-lies] Replaced django.utils.simplejson by system json



commit a1b2b79fcd73e84b19da33c1da162e0df036ef21
Author: Claude Paroz <claude 2xlibre net>
Date:   Thu Mar 28 23:26:36 2013 +0100

    Replaced django.utils.simplejson by system json

 common/fields.py |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/common/fields.py b/common/fields.py
index 1794c96..960d063 100644
--- a/common/fields.py
+++ b/common/fields.py
@@ -1,11 +1,12 @@
 #-*- coding: utf-8 -*-
 # From: http://djangosnippets.org/snippets/1979/
+import json
 
 from django import forms
 from django.core import exceptions
 from django.core.serializers.json import DjangoJSONEncoder
 from django.db import models
-from django.utils import simplejson
+
 
 class DictionaryField(models.Field):
     description = "Dictionary object"
@@ -22,7 +23,7 @@ class DictionaryField(models.Field):
             return {}
         elif isinstance(value, basestring):
             try:
-                return dict(simplejson.loads(value))
+                return dict(json.loads(value))
             except (ValueError, TypeError):
                 raise exceptions.ValidationError(self.error_messages['invalid'])
 
@@ -37,7 +38,7 @@ class DictionaryField(models.Field):
         elif isinstance(value, basestring):
             return value
         else:
-            return simplejson.dumps(value)
+            return json.dumps(value)
 
     def value_to_string(self, obj):
         value = self._get_val_from_obj(obj)
@@ -70,7 +71,7 @@ class JSONField(models.TextField):
 
         try:
             if isinstance(value, basestring):
-                return simplejson.loads(value)
+                return json.loads(value)
         except ValueError:
             pass
 
@@ -83,12 +84,12 @@ class JSONField(models.TextField):
             return None
 
         if isinstance(value, (dict, list)):
-            value = simplejson.dumps(value, cls=DjangoJSONEncoder)
+            value = json.dumps(value, cls=DjangoJSONEncoder)
 
         return super(JSONField, self).get_db_prep_save(value, connection=connection)
 
     def value_to_string(self, obj):
-        return simplejson.dumps(self._get_val_from_obj(obj), cls=DjangoJSONEncoder)
+        return json.dumps(self._get_val_from_obj(obj), cls=DjangoJSONEncoder)
 
 
 # rules for South migrations tool (for version >= 0.7)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]