我正在尝试解析通过 websocket 获得的结果。
sock.onmessage = function(e) {
log(e.data);
}
function log(m) {
var obj = JSON.parse(m);
}
但我得到了错误
SyntaxError: JSON.parse: unexpected character
在服务器上它用python说
def broadcast(self):
response = urllib2.urlopen('http://localhost:8001/json?as_text=1')
data = response.read();
for c in self.clients:
c.sendMessage(data)