chrisjj a day 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 a day ago

    Daniel seems to be pretty confused on this one. All examples produce the correct error response.

  • orangecat a day ago

    That confused me too, apparently it needs to be "\\n".

    • chrisjj 13 hours ago

      /He/ may need it to be //n, but JSON does not. It is valid. https://jsonlint.com/ confirms.

      • Doxin 3 hours ago

        Part 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"}