Reputation: 1404
I should construct and pass following text in my JSON scheme. Here is how it should look:
r"""any-text-goes-here"""
Here is how I decided to construct it:
function make(text) {
return `r"""${text}"""`;
}
The function above takes any string and converts it to desired format. But, when I return it in my API as one of fields of JSON, it looks like following:
"r\"\"\"any-text-goes-here\"\"\""
I want to avoid backslashes. I understand that those slashes is needed by Javascript to properly work, but can I remove them, because client side awaits how I described above. Is it possible technically? How can I solve problem?
Upvotes: 1
Views: 495
Reputation: 943556
JSON strings are delimited by "
characters.
"
characters can be included in a JSON string only by using an escape sequence.
Escape sequences start with a \
.
You can't avoid the backslashes.
See the grammar from the JSON website:
Upvotes: 3