1
我最近從python版本2.7將django服務器轉換爲python版本3.4.1。 我的request.body是一個序列化爲JSON的數組。反序列化時,它將是一個python列表。Python:「import JSON ... json.loads(request.body)」2.7-> 3.4
不幸的是,似乎json.loads不再需要原始字節(這是request.body是什麼)。
我該如何解決這個問題?
def index(request):
if request.method == 'POST':
print("Made it here!")
registered = []
notRegistered = []
print("Is it this?")
print(repr(request.body))
data = json.loads(request.body)
print("Did I make it here?")
最後調用打印從不執行,這就是爲什麼我假設它與
在我來說,我有request.body = STR:JSON =%7B%22layers%22%3A%7B%22BackgroundLayer%22%3 **,和JSON .loads給我錯誤ValueError:沒有JSON對象可以被解碼,爲什麼? – Daviddd