How can I add \n(newline) In Json string

I do not understand what you mean by “json newline”. JSON is a text format which allows you to store data. You can use the newline (ASCII 0xa) character in JSON as a whitespace character.

In Python '\n' is the correct way to represent a newline in a string. So for example this assigns a correct JSON string to the variable data:

data = '{"firstName": "John"}\n'
4 Likes