简体   繁体   中英

tabris.js websocket cant recive anything but a string

I am trying very hard and losing my patience with trying to send a simple array across to tabris.js

using this ws.send(JSON.stringify(["friendArray",{data: results}])) i have to stringify it or it just crashes my tabris app for no reason but when i go to JSON.parse() it. it keeps just giveing me an error Unexpected token 1 in JSON at psotion 0

I'm honestly at a loss I don't know what I could be doing wrong it could be something super simple but I'm frying my brain just trying to come up with a way to transport this simple information could someone please point me in the right direction

try something like, I assume results is some kind of variable, you just need to put data key in double quotes.

JSON.stringify(["friendArray",{data: results}])

to -

JSON.stringify(["friendArray",{"data": results}])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM