Hi there,
I'm using Version 2.4.6-stable+timestamp.2013.05.17.14.52.19, Running on
mac, Python 2.7.2, no external JSON library installed.
Sending the following data via PUT, application/json; charset=UTF-8:
{"id": 3}
results in a JSON parser error occurring at main.py:
if is_json:
try:
logging.info('before') <--- my addition
json_vars = sj.load(body)
logging.info('after') <--- my addition
body.seek(0)
except Exception, e: <--- my addition
logging.exception(e) <--- my addition
# incoherent request bodies can still be parsed "ad-hoc"
json_vars = {}
pass
# update vars and get_vars with what was posted as json
request.get_vars.update(json_vars)
request.vars.update(json_vars)
INFO 2013-05-24 00:07:21,100 main.py:337] before
INFO 2013-05-24 00:07:21,100 main.py:338] <module 'json' from
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py'>
ERROR 2013-05-24 00:07:21,100 main.py:346] No JSON object could be
decoded
Traceback (most recent call last):
File "/Projects/www/app/gluon/main.py", line 340, in parse_get_post_vars
json_vars = sj.load(body)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py",
line 278, in load
**kw)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py",
line 326, in loads
return _default_decoder.decode(s)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py",
line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py",
line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
Appears to be related to the id() function for some reason, as changing the
attribute name to anything other than "id" works fine.
Help on built-in function id in module __builtin__:
id(...)
id(object) -> integer
Return the identity of an object. This is guaranteed to be unique among
simultaneously existing objects. (Hint: it's the object's memory
address.)
If I explicitly force it to use contrib.simplejson. i.e. change the top of
main.py
try:
import simplejson as sj #external installed library
except:
try:
import contrib.simplejson as sj #pure python library <--- Pasted.
except:
import contrib.simplejson as sj #pure python library
I get the same result.
Any ideas?
Thanks in advance,
Matt
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.