Added decorator to produce structured response

@czue 
http://manage.dimagi.com/default.asp?131002
How about naming this something like `json_error`