Skip to content

Commit

Permalink
new support for python 3 in json decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Dec 12, 2014
1 parent bf336b5 commit cf40f87
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/appier/util.py
Expand Up @@ -207,8 +207,10 @@ def request_json(request = None, encoding = "utf-8"):
# "load" it as json data, in case it fails gracefully
# handles the failure setting the value as an empty map
data = request.data
if legacy.is_bytes(data): data = data.decode(encoding)
try: data_j = json.loads(data)
try:
is_bytes = legacy.is_bytes(data)
if is_bytes: data = data.decode(encoding)
data_j = json.loads(data)
except: data_j = {}
request.properties["_data_j"] = data_j

Expand Down

0 comments on commit cf40f87

Please sign in to comment.