HTML string as a JSON output using C#.
I want to replace every instance of ", that is between HTML wrapper < and > with ', while converting to JSON. At the same time if it has text with " quote then it should not be replaced with the ' quote. E.g. "since the 1500s"
Code - Which is replacing all " to ' quotes
public string Content
{
get
{
return _content;
}
set
{
if (value != null)
{
this._content = this._content.Replace("\"", "'");
}
}
}
I am getting string in this form, from my View.
E.g. model.Content = "<p> Lorem Ipsum is simply dummy text of the printing <span id= "#" ids= "#" display= "inline" ></ span > and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever "since the 1500s".<br></p>";
I am using JsonConvert.SerializeObject
string output = JsonConvert.SerializeObject(model, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
Expected string - All double quotes in the HTML tags should be converted into single quote but the text quotes should be as it is using C#
"content": "<p><b>Lorem Ipsum</b> is simply dummy <i>text </i>of the printing <span id='#' ids='#' display='inline'></span> and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever \"since the 1500s\".</p>",