With the following code I am creating an object to pass to a webservice. The single quote seems to be handled with a replace in the stringify before the object is passed to the service, but I don't know how to modify the double quote. If I inspect the Program.Comments field it would show the string like \"Word". This will cause an error in the stringify.
Is this an incorrect way to use the stringify for Json
Program = new Object();
Program.Field1 = $('#txtField1').val();
Program.Field2 = $('#ddlField2').val();
Program.Field3 = $('#lblField3').text();
Program.Field4 = $('#ddlField4').val();
Program.Field5 = $('#ddlField5').val();
Program.Field6 = $('#ddlField6').val();
// This field may contain both single and double quotes
Program.Comments = $('#txtComments').val();
Program.Field7 = $('#txtField7').val();
Program.Field8 = $('input[name=chbField8]').is(':checked');
// This will fix the issue of a single quote
vdata = JSON.stringify(Program).replace(/'/g, "\\'");d