Click here to Skip to main content
15,887,249 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my WCF Service, I have a service method which returns response in JSON format. But when I call the service I get the JSON response with lots of escape characters inside it. I understand that this the way C# represents a string with double quotes. But in some or other way I want to get a clean Json as a response.

My Current response is;

{"GetMDXResponseResult":"{\" : [{\"cubeDatabaseName\" : \"Adventure Works DW 2008R2\",\"cubeName\" : \"Adventure Works\",\"cubeBaseName\" : \"\"},{\"cubeDatabaseName\" : \"Adventure Works DW 2008R2\",\"cubeName\" : \"Mined Customers\",\"cubeBaseName\" : \"\"}]}"}

But I want to have my response as;

{"GetMDXResponseResult":[{"cubeDatabaseName":"Adventure Works DW 2008R2","cubeName":"Adventure Works"},{"cubeDatabaseName":"Adventure Works DW 2008R2","cubeName":"Mined Customers"}]}


Any help on this will be highly appreciated.

Thanks;

Bhaskar
Posted
Comments
[no name] 29-Aug-13 5:48am    
The String class has a handy dandy Replace function.....

1 solution

Normal JSON does not have escapes for quotes unless they are within quoted areas, you are probably viewing this in the debugger where c# encoding is done for strings etc.

If there are escapes then the JSON is invalid.
 
Share this answer
 

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