I’m trying to extend strings and create a simple function that makes the string “JSON safe”.
public static string ToJSON(this object obj)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(obj);
}
But when I run the testcode:
string msg= _rep.GetResource("Delete_Confirm").ResourceValue.ToJSON();
It seems to add extra ” around the string like this:
“”Are you sure you want to delete \”Helo KittY\”?””
the output is correct: a json string is enclosed in double quotes.
The first double quote you see comes from your programming environment, it means this is a string in C#.
The second double quote is a real double quote char and it means start of a json string.
same goes for the two doble quotes at the end.
Hope this helps