Click here to Skip to main content
15,918,889 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My string is :

C#
string success = "";
success = "{\"status\": \"Invalid Key\"}";
this.Context.Response.ContentType = "application/json; charset=utf-8";
this.Context.Response.Write(serializer.Serialize(success));

i got output as:

C#
"{\"status\": \"Invalid Key\"}"


i want output like:

C#
{"status": "Invalid Key"}


What I have tried:

C#
string success = "";
success = "{\"status\": \"Invalid Key\"}";
this.Context.Response.ContentType = "application/json; charset=utf-8";
this.Context.Response.Write(serializer.Serialize(success));
Posted
Updated 27-May-16 9:08am
v2

1 solution

The slash will not appear in the actual output, they are only needed when you are embedding strings with special characters like " in c# source files, this is called "escaping".

You can also remove the serializer.Serialize(success) from your code and just send the success.
 
Share this answer
 
Comments
Member 11466758 27-May-16 6:05am    
Thanks
[no name] 8-Jun-16 8:08am    
http://www.codeproject.com/Questions/1098803/How-to-convert-string-to-date-format-mm-dd-yyyy

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900