Orsay Orsay - 4 months ago 7
Ruby Question

Delete elements from string + transform it into array

I have this string :

data = "[\"super\", \"cool!\", \"bien écrit\", \"first!\", \"why is everyone speaking French here?\"]"


I would like to transform it to be like :
data = ["super", "cool!", "bien écrit", "first!", "why is everyone speaking French here?"]

Answer

Parse it like a JSON. Try

require 'json'
data = JSON.parse data