Replacing escape characters

There is no backslash in the string.

The \" combination is used to “escape” the doublequote to be able to use it in the string.

If you were writing "{"year":"2020"}" it where a syntax error, as there is no operator between "{" and the variable year, etc.

If you were printing the string "{\"year\":\"2020\",\"p\":\"1002\"}" you’d see {"year":"2020","p":"1002"}.

4 Likes