socket.io-client icon indicating copy to clipboard operation
socket.io-client copied to clipboard

Conflicts with JSON and other items if using prototype.js library

Open crickeys opened this issue 14 years ago • 2 comments

I've noticed that if you have the prototype.js library installed on your page then the socket.io-client isn't going to work right. I've narrowed down a few of the issues to the fact that the prototype.js library override Array's toJSON function. And if your browser has nativeJSON then the browser is going to call that toJSON function which is going to mess up functions like stringify which socket.io-client uses heavily.

The final problem being that if I emit something to the server it ends up being malformed and, in my case, ends up sending an ARRAY instead of an OBJECT.

I'm not sure the best approach here. Perhaps relying on nativeJSON should be removed?

crickeys avatar Jan 09 '12 07:01 crickeys

Hi, any news on this? @crickeys, did you manage to work around this eventually?

farnoux avatar Apr 15 '13 16:04 farnoux

easiest solution would be using JSON3 instead of JSON2 which detects all these fuckups.

3rd-Eden avatar Apr 15 '13 17:04 3rd-Eden