1

A case of html as below: 1.<input type="text">, the input is "aa\r\nbb" 2.<textarea></textarea>, the input is "aa", "bb" and a newline between them.

Then I get the data from backend is both "aa\r\nbb"

But when I transfer it into JSON with some tools, the result is different.

<input type="text"> ,the result is "aa\\r\\nbb",

but for textrea part, the result is still is "aa\r\nbb" .

So why isn't the "\" of textarea transfered to "\\"?

user1703055
  • 149
  • 2
  • 9
  • because entering \r\n in an input field is not the same as a line break. – Gerald Schneider Sep 09 '14 at 13:43
  • Is it "ab" in both cases or is it a string containing the backslashes? – amphetamachine Sep 09 '14 at 13:51
  • somewhere during the translation to JSON, something is probably "escaping" special characters. it's common when you're dealing with a reduced character set. i'm not knowledgeable about JSON, so I can't provide a full answer. – Woodrow Barlow Sep 09 '14 at 14:16
  • possible duplicate of [How do I handle newlines in json?](http://stackoverflow.com/questions/42068/how-do-i-handle-newlines-in-json) – Palpatim Sep 09 '14 at 14:36

0 Answers0