Permalink
Browse files

add to_json to return pure json, not the json wrapped in an httpresponse

  • Loading branch information...
wiswaud committed Feb 9, 2012
1 parent b525fd4 commit cd4c91d998612dadb4ed4736ac36a241abc51d56
Showing with 4 additions and 1 deletion.
  1. +4 −1 wapiti/parsers.py
View
@@ -131,8 +131,11 @@ def __init__(self, format, jsonp=None):
self.encode = getattr(self, format)
self.jsonp = jsonp
+ def to_json(self, value):
+ return json.dumps(self.convert(value))
+
def json(self, value):
- resp = json.dumps(self.convert(value))
+ resp = self.to_json(value)
if self.jsonp:
jsonp = re.sub(r'[^a-zA-Z0-9_]', '', self.jsonp)
resp = u'%s(%s)'%(jsonp, resp)

0 comments on commit cd4c91d

Please sign in to comment.