Reputation: 1463
I am testing an application where I wish to input some text into a textfield and see if the application accepts it or raises an error. I am using postman and reading from a json data file with my different entries.
I wish to include an entry like thisL
{
"name": "namewith\test",
},
However using this I get an error:
Unexpected control character at 1:25
I have tried this:
{
"name": "namewith\\test",
},
this:
{
"name": "namewith\/test",
},
this
{
"name": "namewith'\'test",
},
How can I include this backslash and not have it recognized as an escape character?
Upvotes: 0
Views: 3724
Reputation: 1188
May this idea help.
var customerData = document.getElementById("inputText").val();
var json = {
name: customerData
}
var jsonString = JSON.stringify(json); //you get the content parsed
Upvotes: -1
Reputation: 369
The correct way is \\
Your answer:
{
"name": "namewith\\test",
},
should work. It works for me. Is there an object after this? That trailing comma could be a problem - unlike JS, JSON doesn't accept an extra comma at the end.
What error are you getting for this option.
Upvotes: 2