Update: When you access a page that produces JSON as output with the chrome browser. Incorrect results are shown.
Consider this django code that produces json. When you json.dumps
a long
, the two digits are different from the expected value. Here is the code:
from django.http import JsonResponse, HttpResponse
import json
def dumps1(request):
return JsonResponse({'pk': 456011173705795438 })
def dumps2(request):
return HttpResponse(json.dumps({'pk': 455928532169112023 }))
Naturally, you would expect dumps1
to return and HttpResponse with the body as {'pk': 456011173705795438 }
while dumps2 should return {'pk': 455928532169112023 }
but actual results are
{
pk: 456011173705795460
}
and
{
pk: 455928532169112000
}
Notice that in both cases, the last two digits in the number have changed. If you open the django shell and type in json.dumps({'pk': 455928532169112023 }) the correct output is produced.
Django 1.8.5 and python 2.7.6 ( ipython 4.0.b1)
Is this a bug or a feature?