json replace backslash to double quote

  javascript

Hello guys I’m here again.
I meet a problem that is I use Web Api’s HTTP GET method to get json data which is in my database.
The code will be:

VifundaController.cs

[HttpGet]
        public string Query2(string str1, string str2)
        {
            string SQL = "";
            StringBuilder builder = new StringBuilder();
            Hashtable parameters = new Hashtable();
            DBController l_dbc = new DBController("UseDB");
            DbConnection conn = l_dbc.NewConnection();
            DbTransaction trans = conn.BeginTransaction();

            
            SQL = ("SELECT * FROM vibfcash WHERE bfcash_year = @year and bfcash_stage = @stage");

            parameters.Add("@year", new StructureSQLParameter(str1.ToString(), SqlDbType.NVarChar));
            parameters.Add("@stage", new StructureSQLParameter(str2.ToString(), SqlDbType.NVarChar));

            DataTable dt = new DataTable();
            dt = l_dbc.FillDataTable(builder.ToString(), parameters, false);

            string str_json = JsonConvert.SerializeObject(dt);
            string js = str_json;

            return js;
        }

Then when I use http://localhost/api/vifundna/Query2?str1=109&str2=2 to call api,
the api return to screen’s string is with backslash and double qoutes like: "
So how to replace backslash and double qoutes " to only double qoutes " ?
Thank you guys!!! 🙂

Source: Ask Javascript Questions

LEAVE A COMMENT