I want to read data.txt file and output the same as string2, but when I read from the file Ruby prints the backslashes, why is that so and how can I avoid it?
data.txt contains
\",\"foo\":{\"id\":1111,\"name\":\"Bar\",
file = File.open("data.txt", "r")
string1 = file.read
puts "string1: #{string1}"
string2 = "\",\"foo\":{\"id\":1111,\"name\":\"Bar\","
puts "string2: #{string2}"
Output
$ ruby test.rb
\",\"role\":{\"id\":1111,\"name\":\"Mobile\",
","role":{"id":1111,"name":"Mobile",
My goal is to read data.txt and output ","role":{"id":1111,"name":"Mobile",