I have contstructed a string in Rails:
text = 'Example, first line\nExample, second line'
so far, so good. I want to print this in a UILabel in my app, so I pass it to my app as JSON. Problem is, Rails spits this string out as
{"test":"Example, first line\\nExample, second line"}
Note the double escape of the backslash. When iOS interprets this JSON, it rightly strips only one escape and prints the literal \n in the label, rather than interpreting a line break.
How can I get rails to output the text variable as
{"test":"Example, first line\nExample, second line"} //note the single escape
without being hacky?
Single quotes prevent escapes.
Try this: