How to clarify existing json data using asp.net

Below is the JSON data that is generated somehow:

[
  {
    id: "1926d769-319b-41ec-8bba-deabbcc44992",
    start: "2014-09-02T11:00:00",
    end: "2014-09-02T12:00:00",
    title: ""ATR" Recieved by Lender - First",
    body: ""ATR" Recieved by Lender - First",
    color: "",
    editable: false,
    officeEvent: false,
    allDay: false
  },
  {
    id: "37e65cc0-a44a-460d-acc6-f8847fcdc384",
    start: "2014-08-04T12:00:00",
    end: "2014-08-04T13:00:00",
    title: "Sign Disclosures",
    body: "Sign Disclosures",
    color: "",
    editable: false,
    officeEvent: false,
    allDay: false
  }
]

      

The first title and body element contains a double quote ("") to make the JSON data display an error. Now how can I avoid this quote from all JSON data at the same time as below.

title: "\" ATR \ "Received by the lender first"

How can I achieve this in Asp.Net C #?

+3


source to share


1 answer


Brian is right, you really need to talk to the seller and fix their details / code. To work without using a loop, though you can use string replacement techniques to clean up JOSN.

string cleanJson = source.toString();
string cleanJson = cleanJson.Replace("title: \"\"", "title: \"\\\"");
string cleanJson = cleanJson.Replace("body: \"\"", "title: \"\\\"");
return convertBackToJson(cleanJson);

      



If you don't want to use a loop for performance reasons, this might not be the best solution. if you want to speed things up, consider trying to split the JSON into chunks, if you can isolate the dummy entries, clean them up and add them to the final output.

0


source







All Articles