array = []
File.open(file.txt) do |f|
f.lines.each do |line|
array << line.split.map(&:to_s)
end
end
puts purgeObject
@test = {
"strings" => array
}.to_json
puts @test
I need strings the output to be the following way. I keep getting an array of arrays i.e. [["334455"], ["ABC"]] - what's wrong?
{
"strings" : [
"334455",
"ABC"
]
}
File.open { .. }, did you check the output ofarray?array << line.split.map(&)... where is the method name inarray << line.split.map(&..???)array << line.split.map(&:to_s). Thanks.puts array, after the block..Arraysis good now.@testreturn[["334455"], ["ABC"]]