C # automatically outputs double quote character with backslash

I am writing a parser and website analyzer.

And I am creating a JSON object from the parsed parameters. For example, a website has a title Buy best phones from "NOKIA COMPANY LTD"

As you can see, the title has a double quote character: "

So when I parse the title, I get this:

Buy best phones from \"NOKIA COMPANY LTD\" and call anyone

Then I create a JSON object to be used by third party developers. I am using JSON newton soft library like this =

 var obj = new 
    { 
      Title = parsedTitle, 
      H1 = "some h1"
    };

      

JsonConvert.SerializeObject(obj, settings);

And like outside, I am getting invalid json, so frontend devs get error.

The JSON output will be something like this:

{
  "title": " Buy best phones from \\"
   NOKIA COMPANY LTD\\" and call anyone",
  "h1:: "some h1"
}

      

As you can see, this is not valid JSON. What should I do?

+3
json c # asp.net asp.net-mvc


source to share


No one has answered this question yet

See similar questions:

8
Why does .NET add an extra forward slash to the already existing forward slashes in the path?
6
Turn c # object into json string, how to handle double quote

or similar:

495
Can I escape the double quote in a shorthand literal?
390
What does the @ symbol in front of a variable name mean in C #?
196
How to avoid double quotes in JSON
144
How to use NSJSONSerialization
118
jQuery sends valid json to request body
58
Escape double quotes in a string
15
JSON.stringify strips double quotes every time strified
2
Parsing non-standard JSON
2
DotNetBrowser: passing json string from .Net to JavaScript function taking json object
1
Parse read-only string with quotation marks in JSON



All Articles
Loading...
X
Show
Funny
Dev
Pics