I try to test a view, I receive a json request from the IPad, the format is:
req = {\"custom_decks\": [
{
\"deck_name\": \"deck_test\",
As I was having problems with getting JSON data from HttpRequest directly with the code of the other answer:
data = json.loads(request.body)
custom_decks = data['custom_decks']
error:
the JSON object must be str, not 'bytes'
Here is an update of the other answer for Python version >3:
json_str=((request.body).decode('utf-8'))
json_obj=json.loads(json_str)
Regarding decode('utf-8'), as mention in:
RFC 4627:
"JSON text shall be encoded in Unicode. The default encoding is UTF-8."
I attached the Python link referred to this specific problem for version >3.
http://bugs.python.org/issue10976