﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29420	Single quote in json bytes from RequestFactory	Dunatotatos	nobody	"Hi all,

If we use RequestFactory to build a JSON request, the body of the request is built with single quotes instead of double-quotes. However, According to [http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf ECMA-404], chapter 9-String:
    A string is a sequence of Unicode code points wrapped with quotation marks (U+0022).

Using the standard `json` library to load this payload raises an Exception.

Here is a MVP to run in a Django console:

{{{
>>> import json
>>> from django.test import RequestFactory
>>> 
>>> data = {'key': 'value'}
>>> request = RequestFactory().post('/', data, content_type='application/json')
>>> request.body # Here, we see the JSON has been encoded with single quotes.
b""{'key': 'value'}""
>>> json.loads(request.body) # And json.loads refuses the single quote
Traceback (most recent call last):
[...]
json.decoder.JSONDecoder: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
}}}

If this is an expected behavior, it should probably be documented somewhere in [https://docs.djangoproject.com/en/2.0/topics/testing/advanced/#the-request-factory this page], as well as how to POST a JSON request. Except if I miss something, of course."	Bug	closed	Testing framework	2.0	Normal	duplicate	requestfactory, json		Unreviewed	0	0	0	0	0	0
