Removing requirement for simplejson and using Python 2.6 built-in JSON

if available, otherwise we fallback to simplejson.

Improved the default jsonification rule for datetime and date objects.
This commit is contained in:
Jonathan LaCour
2010-09-29 00:05:04 -04:00
parent 972579b687
commit 21ad8ea6f2
3 changed files with 6 additions and 6 deletions

3
README
View File

@@ -6,7 +6,4 @@ TODO
* Switch "hooks" over to Context Managers.
* Remove requirement for simplejson, since we should be using
Python's built-in JSON.
* JSONify dates as isoformat strings by default.

View File

@@ -1,4 +1,8 @@
from simplejson import JSONEncoder, dumps
try:
from json import JSONEncoder, dumps
except ImportError:
from simplejson import JSONEncoder, dumps
from datetime import datetime, date
from decimal import Decimal
from webob.multidict import MultiDict
@@ -28,7 +32,7 @@ class BaseEncoder(JSONEncoder):
if hasattr(obj, '__json__') and callable(obj.__json__):
return obj.__json__()
elif isinstance(obj, (date, datetime)):
return str(obj)
return obj.isoformat()
elif isinstance(obj, Decimal):
return float(obj)
elif self.is_saobject(obj):

View File

@@ -19,7 +19,6 @@ setup(
zip_safe = True,
install_requires=[
"WebOb >= 0.9.8",
"simplejson >= 2.0.9",
"simplegeneric >= 0.7",
"Genshi >= 0.6",
"Kajiki >= 0.2.2",