How to avoid escaping characters in Prolog strings (Discussion)

Just for the record, double quoted (string) and single quoted (atom) behave the same wrt newlines. Of course, if you have double quotes in the input (e.g., JSON), atoms avoid having to escape the JSON double quotes. A SWI-Prolog’s basic text rule is the predicates that require text input accept all representations, open_string/2 works fine.

That said why would you need a hard coded JSON string in your code except when writing tests for a JSON parser?

1 Like