JSON object with cuts in it

I am serializing a json object using:

public static string ToJson(this object obj)
{
    JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
    return jsonSerializer.Serialize(obj);
}

      

However, when I fill in the hidden field, I get forward slashes with it:

"[{\" ImageLink \ ": \" \ ", \" ShowOnHomePage \ ": null, \" Type \ ": \" AdListItem \ ", \" Key \ ": NULL, \" Title \ ": \" dsafdsaf \ ", \" URL \ ": \" fdsafdsa \ ", \" ContentSummary \ ": \" \ u003cdiv \ u003efdsafdsa \ u003c / div \ u003e \ "}, {\" ImageLink \ ": \" \ ", \ "ShowOnHomePage \": null, \ "Type \": \ "AdListItem \", \ "Key \": null, \ "Title \": \ "hddfg \", \ "URL \": \ "dsaf \ ", \" ContentSummary \ ": \" \ u003cdiv \ u003efdsafdsa \ u003c / div \ u003e \ "}, {\" ImageLink \ ": \" \ ", \" ShowOnHomePage \ ": null, \" Type \ ": \ "AdListItem \" \ "Key \ ": null, \" Title \ ": \" asfd \ ", \" URL \ ": \" Asdf \ ", \" ContentSummary \ ": \" \ u003cdiv \ u003eafds \ u003c / div \ u003e \ " }] "

How should I properly get rid of the \ "and replace them with a simple" ???

Any ideas?

Thanks.

0


a source to share


1 answer


Slashes are Javascript string escapes.

\ "->" so you can specify a quote with a quote.



This is true for most C-style languages ​​(C, C ++, C #, Java, etc.)

+2


a source







All Articles