Friday, August 27, 2021

convert json to dataset then convert to json

                 //Replacing the Special Charactor 

                DataSet ds = JObject.Parse(response.Content)["Result"].ToObject<DataSet>();

                ds.Tables[0].AsEnumerable().Where(dr => dr.Field<string>("SiteName").Contains("'")).Select(b => b["SiteName"] = b["SiteName"].ToString().Replace("'", @"\'")).ToList();

                ds.Tables[1].AsEnumerable().Where(dr => dr.Field<string>("Name").Contains("'")).Select(b => b["Name"] = b["Name"].ToString().Replace("'", @"\'")).ToList();


                resultview = new Resultview<DataSet>(ds, Message.Success.ToString(), "Success");

                return JsonConvert.SerializeObject(resultview);