Ok in my python code. I have this
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)
In javascript
onMessage = function(m) {
var a = JSON.parse(m.data);
alert(a.here); // foo should pop up but it doesnt
}
It seems like the parse method does not work. No alert that pops up. If I remove parse line and put this than alert pops up, if I just change alert and keep parse it still doest do anything;
alert(m.data) // this prints out {"here": "aaa", "there": "bbb"}
So idk why it is not parsing right. I am assuming it has something to do with quotes. I guess I am having trouble with them again.
UPDATE
please look at my answer below, i solved the problem.
So I resolved this problem like this;
var a = JSON.parse(String(m.data));
looks like m.data is not a string after all, so you need to cast it.