4 ms·
That confused me too, apparently it needs to be "\\n".
by orangecat 1y ago
That confused me too, apparently it needs to be "\\n".
- chrisjj 1y ago/He/ may need it to be //n, but JSON does not. It is valid. https://jsonlint.com/ https://jsonlint.com/ confirms.
- Doxin 1y agoPart of the confusion here is that writing '{"key": "value\nda"}' in python is NOT producing a string like this: {"key": "value\nda"} but instead like this: {"key": "value da"} you need to either double-escape it, or use raw strings. In python these both: '{"key": "value\\nda"}' r'{"key": "value\nda"}' will produce the following string: {"key": "value\nda"}
- chrisjj 1y agoCorrection: \\n