You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assuming that many devs are using websockets for chats and other stuff with user's input, it's a bad idea to use eval.
instead, i was able to get json using these commands:
data.gsub!('\"', '"').gsub!('\\\\','\\') # second gsub may be omitted; but without it, unicode chars(non-latin) wont be converted properly
clean_data = JSON.parse(data[1..-2]) # [1..-2] to remove first and last `"` symbol
when an event binding is triggered, "data" variable is returned as a String. I actually had to manipulate it in order to cast it into a Hash type :
data.gsub!('":"','"=>"')
data = eval(data)
makes sense to have the gem cast it into a Hash...
The text was updated successfully, but these errors were encountered: