I have a string with an array of arrays inside:
"[[1, 2], [3, 4], [5, 6]]"
Can I convert this to the array of arrays, without using eval or a regular expression, gsub, etc.?
Can I make turn it into:
[[1, 2], [3, 4], [5, 6]]
The same can be done using Ruby standard libaray documentation - YAML:
require 'yaml'
YAML.load("[[1, 2], [3, 4], [5, 6]]")
# => [[1, 2], [3, 4], [5, 6]]
evalis the most simple way, if you worry about security, check the string with regex to make sure. but seems you don't want both.eval? How much simpler can it be thaneval("[[1, 2], [3, 4], [5, 6]]")?