我正在从Cybertracker应用程序向我的Djanog Rest Framework API发送一个GeoJSON对象。
这是数据进入我的服务器的方式:
if request.method == "POST":
print request.body
>> { "type": "FeatureCollection", "features": [
{ "type": "Feature",
"geometry": { "type": "Point", "coordinates": [0.000000, 0.000000] },
"properties": {
"deviceId": "00000000-7678-5656-0732-23e40033c587",
"id": "185e0c80-9d29-1314-9b8c-167bd853aab8",
"dateTime": "Not implemented",
"sighting": {
"species": "White rhino",
"count": 2,
"activity": "Standing in shade",
"temp": 34
}
}
},
{ "type": "Feature",
"geometry": { "type": "Point", "coordinates": [0.000000, 0.000000] },
"properties": {
"deviceId": "00000000-7678-5656-0732-23e40033c587",
"id": "74ca6c6c-6a1d-4410-b816-fe34a2c95f66",
"dateTime": "Not implemented",
"sighting": {
"species": "Black rhino",
"count": 1,
"activity": "Feeding",
"temp": 28
}
}
}
]}
我尝试解析数据但问题相同:
print json.loads(request.body)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 369, in decode
raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 30 column 3 - line 30 column 4 (char 843 - 844)
print JSONParser().parse(request)
File "/Users/hermanstander/apps/afriapps/rhino_monitoring/env/lib/python2.7/site-packages/rest_framework/parsers.py", line 68, in parse
raise ParseError('JSON parse error - %s' % six.text_type(exc))
ParseError: JSON parse error - Extra data: line 30 column 3 - line 30 column 4 (char 843 - 844)