2

The code below ends up printing failure.

    try:
        print request.raw_post_data
        json_data = simplejson.loads(request.raw_post_data)
    except:
        print "failure"

The out put of the first print is

    JSON: {"password":"wfbarks","email":"wfbarks","username":"wfbarks"}

Does anybody know what is wrong this this?

3
  • You should avoid using "catch-all" excepts as they will make debugging a lot harder, or just raise the exception. Commented Nov 29, 2011 at 2:17
  • Thanks for the advice, I just threw that in there to figure out where the problem was, for this case. Commented Nov 29, 2011 at 2:37
  • You could then use a raise statement in your except clause so you can get the traceback ;) Commented Nov 29, 2011 at 11:43

1 Answer 1

2

The JSON: part is not valid JSON. Strip it before loads. The remainder (i.e. {"password":"wfbarks","email":"wfbarks","username":"wfbarks"}) should be valid JSON.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.