Sunday, February 28, 2010

Testing JSON django fixtures

My JSON testing fixture for django was bad, and django gave a really unhelpful error:
ValueError: No JSON object could be decoded

A line number would have been nice, jeez. To find out what the actual problem was I used the json module in ipython:

import json
a=open("testing.json",'r').read()
json.loads(a)

Which will either work, or give you a line number for the problem :)

1 comment:

GamesBook said...

Great! Saved me a whole bunh of frustration - why can't Django include the line number in the stack trace??