Below is MY DTO.
public class CustomerTO
{
  public int CustomerId { get; set;}
  public string CustName { get; set;}
  public string CustJson { get; set;}
}
Below is my LINQ to get Customer records.
var query = (from c in entities.tblCustomers
             select c).toList<CustomerTO>();
This returns the customer collection & in the UI I gets collection as.
Sample:-
    {  
    "CustomerId":113,
    "CustName":"Ram",
    "CustJson":""{\r\n  \"Number\": 143,\r\n  \"IsDeleted\": false,\r\n  \"GapAnalysisChecked\": false,\r\n  \"ShowGraphics\": true,\r\n  \"Impact\": {\r\n    \"Value\": \"DefaultNodeTitle_Impact\",\r\n    \"Details\": null,\r\n    \"DefaultValue\": \"DefaultNodeTitle_Impact\"}
   }
I'm in need to get a valid json string in CustJson varialble.
Please note that in the db, the stored data in CustJSON column is a valid json string.
So I tried this.
foreach(var cust in customers)
{
   if(cust.CustJson != null)
   {
     var parsedJson = JsonConvert.DeserializeObject(cust.CustJson); // this give a valid json
    cust.CustJson  = JsonConvert.SerializeObject(parsedJson);// but this creates a string with \r\n
   }
}
When I try this, in parsed JSON I get the desired JSON. However, when Serialize the parsed JSON again the same string returns.
How do I get the valid json string in Cust.Json??
Is there a better way to get the valid json without the foreach loop?
 
    