我在 python 中解码这个 json 时遇到了一些问题。
从 basehttpserver 我回来了
[
{
"changed_aspect": "media",
"object": "geography",
"object_id": "1306",
"subscription_id": 1326,
"time": 1300570688
}
]
我将其放入 simplejsondecoder 中
data = simplejson.loads(s)
但是当我查看数据的长度时,它会返回 1,而不是我期望的 json 对象的 5。
这是所有代码,以防问题出在其他地方。
class httpserver(BaseHTTPServer.BaseHTTPRequestHandler):
def do_POST(self):
self.data_string = self.rfile.read(int(self.headers['Content-Length']))
self.send_response(200)
self.end_headers()
data = simplejson.loads(self.data_string)
print len(data)
return