我有这个字符串:
data = "[\"super\", \"cool!\", \"bien écrit\", \"first!\", \"why is everyone speaking French here?\"]"
我想将其转换为:
data = ["super", "cool!", "bien écrit", "first!", "why is everyone speaking French here?"]
答案 0 :(得分:3)
将其解析为JSON。尝试
require 'json'
data = JSON.parse data
答案 1 :(得分:1)
数据看起来像JSON。使用JSON.parse(data)