I have a GeoDjango model object that I do not want to serialize for json. I do it in my opinion:
lat = float(request.GET.get('lat'))
lng = float(request.GET.get('lng'))
a = Authority.objects.get(area__contains=Point(lng, lat))
if a:
return HttpResponse(simplejson.dumps({'name': a.name,
'area': a.area.geojson,
'id': a.id}),
mimetype='application/json')
The problem is that simplejsontreats a.area.geojson as a simple string, even if it is a beautifully pre-generated json. It is easily fixed in the client eval()in the area, but I would like to do it correctly. Can I say simplejsonthat the specific string is already json and should be used as-is (and not returned as a simple string)? Or is there another workaround?
UPDATE
To clarify, this is json, which is currently being returned:
{
"id": 95,
"name": "Roskilde",
"area": "{ \"type\": \"MultiPolygon\", \"coordinates\": [ [ [ [ 12.078701, 55.649927 ], ... ] ] ] }"
}
The challenge is to "area" be a json dictionary instead of a simple string.