Remove illegal character from JSON string before deserializing in c#
<p>I am getting a JSON response from third party which I cannot control. Sometime this response throws illegal characters at the end of the string. Here is an example of correct one.</p>

<pre class="lang-json prettyprint-override"><code>{
    "result": [
        {
            "parent": "",
            "made_sla": "true",
            "caused_by": "",
            "watch_list": "",
            "upon_reject": "cancel",
            "sys_updated_on": "2016-09-13 19:00:01",
            "approval_history": "",
            "category": "SPIN Station"
        }
    ]
}
</code></pre>

<p>An example of wrong string. Here you can see at last it throwing extra comma instead of closing.</p>

<pre class="lang-json prettyprint-override"><code>{
    "result": [
        {
            "parent": "",
            "made_sla": "true",
            "caused_by": "",
            "watch_list": "",
            "upon_reject": "cancel",
            "sys_updated_on": "2016-09-13 19:00:01",
            "approval_history": "",
            "category": "SPIN Station"
        }
    ],
</code></pre>

<p>Here is my code in c#. Can anyone tell how to replace the illegal comma with closing curly bracket in the response value string in the code below before deserializing</p>

<pre class="lang-csharp prettyprint-override"><code> WebRequest req = WebRequest.Create(@"https://aaaa.service-now.com/api/now/table/incident?sysparm_query=sys_updated_onBETWEENjavascript:gs.dateGenerate('2016-09-10','00:00:00')@javascript:gs.dateGenerate('2016-09-13','23:59:59')");
     req.Method = "GET";
     req.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("username:Password"));
     req.ContentType = "application/xml";

     HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
     var responseValue = string.Empty;
     using (var responseStream = resp.GetResponseStream())
     {

          if (responseStream != null)
              using (var reader = new StreamReader(responseStream))
                  responseValue = reader.ReadToEnd();
     }

     JavaScriptSerializer ser = new JavaScriptSerializer();
     ser.MaxJsonLength = 2147483647;
     ser.RegisterConverters(new List&lt;JavaScriptConverter&gt; { new ResultConverter() });
     RootObject ro = ser.Deserialize&lt;RootObject&gt;(responseValue);
</code></pre>