私のpythonコードでOK。私はこれを持っています
foo = "aaa"; //foo and bar are variables that change, just an example here
bar = "bbb";
json = {"here": foo, "there": bar} //also tried single quotes
message = simplejson.dumps(json) //also tried just json instead of simplejson
channel.send_message(user_id(), message)
JavaScriptで
onMessage = function(m) {
var a = JSON.parse(m.data);
alert(a.here); // foo should pop up but it doesnt
}
parse メソッドが機能しないようです。ポップアップするアラートはありません。解析行を削除してアラートがポップアップするよりもこれを置くと、アラートを変更して解析を続けると、何もしません。
alert(m.data) // this prints out {"here": "aaa", "there": "bbb"}
だから、なぜそれが正しく解析されていないのか。私はそれが引用符と関係があると仮定しています。私は彼らと再び問題を抱えていると思います。
アップデート
以下の私の答えを見てください、私は問題を解決しました。