I want to import my CSV file to my database, my CSV file has following string and I need to parse it to a Ruby array object, how to do that?
"[\"Mt Roskill\", \"Sylvia Park\"]"
That example string looks like JSON. Use JSON.parse
to return a Ruby array:
require 'json'
JSON.parse("[\"Mt Roskill\", \"Sylvia Park\"]")
#=> ["Mt Roskill", "Sylvia Park"]