If you manually parse the json yourself using json.loads(request.body) what is the result? This is really all json_body does.
Hey guys,I'm just trying to send a simple json to my callable view using this beneath. But when the method execution reach request.json_body I alway got an ValueError.But it's funny because if I'd change request.json_body to request.body, que program prints the json string correctly. So, this is a bug?Command :curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"user":{"first_name":"firstname","last_name":"lastname"}}' http://localhost:6543/hello
This is my callable view:@view_config(name='hello',renderer='string')def hello(request):print request.json_bodyreturn 'OK'Erro message:Traceback (most recent call last):File "D:\Users\u30941.MATRIZ\workspace\myenv\lib\site-packages\pyramid_debugtoolbar-1.0.4-py2.7.egg\pyramid_debugtoolbar\toolbar.py", line 122, in toolbar_tweenresponse = _handler(request)File "D:\Users\u30941.MATRIZ\workspace\myenv\lib\site-packages\pyramid_debugtoolbar-1.0.4-py2.7.egg\pyramid_debugtoolbar\panels\performance.py", line69, in noresource_timer_handlerresult = handler(request)File "D:\Users\u30941.MATRIZ\workspace\myenv\lib\site-packages\pyramid-1.4-py2.7.egg\pyramid\tweens.py", line 21, in excview_tweenresponse = handler(request)File "D:\Users\u30941.MATRIZ\workspace\myenv\lib\site-packages\pyramid-1.4-py2.7.egg\pyramid\router.py", line 161, in handle_requestresponse = view_callable(context, request)File "D:\Users\u30941.MATRIZ\workspace\myenv\lib\site-packages\pyramid-1.4-py2.7.egg\pyramid\config\views.py", line 345, in rendered_viewresult = view(context, request)File "D:\Users\u30941.MATRIZ\workspace\myenv\lib\site-packages\pyramid-1.4-py2.7.egg\pyramid\config\views.py", line 491, in _requestonly_viewresponse = view(request)File "d:\users\u30941.matriz\workspace\myenv\myproject\myproject\views.py", line 12, in helloprint request.json_bodyFile "D:\Users\u30941.MATRIZ\workspace\myenv\lib\site-packages\pyramid-1.4-py2.7.egg\pyramid\request.py", line 385, in json_bodyreturn json.loads(text_(self.body, self.charset))File "C:\Python27\Lib\json\__init__.py", line 326, in loadsreturn _default_decoder.decode(s)File "C:\Python27\Lib\json\decoder.py", line 366, in decodeobj, end = self.raw_decode(s, idx=_w(s, 0).end())File "C:\Python27\Lib\json\decoder.py", line 384, in raw_decoderaise ValueError("No JSON object could be decoded")ValueError: No JSON object could be decoded--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.