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]]
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]]