2 ms·
> {"key": "value\nda"} > My convention is that \n is the one-byte ASCII control character linefeed. This JSON is not valid. How is this not valid?
by chrisjj 1y ago
> {"key": "value\nda"}
> My convention is that \n is the one-byte ASCII control character linefeed. This JSON is not valid.
How is this not valid?
- rurban 1y agoDaniel seems to be pretty confused on this one. All examples produce the correct error response.
- orangecat 1y agoThat 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