Permalink
Browse files

Switch to ujson

  • Loading branch information...
1 parent a705ae4 commit c8584aace447b2efeff386f2bb54cd5e7e23cd86 @colinhowe committed Jul 23, 2012
Showing with 9 additions and 10 deletions.
  1. +1 −1 REQUIREMENTS
  2. +5 −6 src/facegraph/api.py
  3. +1 −1 src/facegraph/fql.py
  4. +2 −2 src/facegraph/graph.py
View
2 REQUIREMENTS
@@ -1,2 +1,2 @@
bunch>=1.0.1
-simplejson>=2.4.0
+ujson>=1.19
View
11 src/facegraph/api.py
@@ -1,7 +1,6 @@
import socket
-import simplejson
+import ujson as json
from urllib import urlencode, unquote
-from simplejson.decoder import JSONDecodeError
FB_READ_TIMEOUT = 180
@@ -103,8 +102,8 @@ def __call__(self, _retries=None, *args, **kwargs):
def __process_response(self, response, params=None):
try:
- data = simplejson.loads(response)
- except JSONDecodeError:
+ data = json.loads(response)
+ except ValueError:
data = response
try:
if 'error_code' in data:
@@ -213,7 +212,7 @@ def __fetch(self, url):
response = self.urllib2.urlopen(url, timeout=self.timeout)
except self.urllib2.HTTPError, e:
response = e.fp
- return simplejson.load(response)
+ return json.load(response)
def verify_token(self, tries=1):
url = "https://graph.facebook.com/me?access_token=%s" % self.access_token
@@ -252,4 +251,4 @@ def __str__(self):
str = "%s, Params: %s" % (str, self.params)
if self.code:
str = "(#%s) %s" % (self.code, str)
- return str
+ return str
View
2 src/facegraph/fql.py
@@ -3,7 +3,7 @@
import urllib2
import bunch
-import simplejson as json
+import ujson as json
from graph import GraphException
from url_operations import add_path, update_query_params
View
4 src/facegraph/graph.py
@@ -10,7 +10,7 @@
add_query_params, update_query_params, get_path)
import bunch
-import simplejson as json
+import ujson as json
from functools import partial
p = "^\(#(\d+)\)"
@@ -395,4 +395,4 @@ def __str__(self):
s += ", Params: %s" % self.params
if self.code:
s += ", (%s)" % self.code
- return s
+ return s

0 comments on commit c8584aa

Please sign in to comment.