title: Error when passing quotes to webservice by AJAX
body: <p>I'm passing data using .ajax and here are my data and contentType attributes:</p>
  
  <pre><code>data: '{ "UserInput" : "' + $('#txtInput').val() + '","Options" : { "Foo1":' + bar1 + ', "Foo2":' + Bar2 + ', "Flags":"' + flags + '", "Immunity":' + immunity + '}}',
  contentType: 'application/json; charset=utf-8',
  </code></pre>
  
  <p>Server side my code looks like this:</p>
  
  <pre><code>&lt;WebMethod()&gt; _
  Public Shared Function ParseData(ByVal UserInput As String, ByVal Options As Options) As String
  </code></pre>
  
  <p>The userinput is obvious but the <code>Options</code> structure is like the following:</p>
  
  <pre><code>Public Structure Options
      Dim Foo1 As Boolean
      Dim Foo2 As Boolean
      Dim Flags As String
      Dim Immunity As Integer
  End Structure
  </code></pre>
  
  <p>Everything works fine when <code>$('#txtInput')</code> contains no double-quotes but if they are present I get an error (for an input of asd"):</p>
  
  <pre><code>{"Message":"Invalid object passed in, \u0027:\u0027 or \u0027}\u0027 expected. (22): { \"UserInput\" : \"asd\"\",\"Options\" : { \"Foo1\":false, \"Foo2\":false, \"Flags\":\"\", \"Immunity\":0}}","StackTrace":"   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth)\r\n   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}
  </code></pre>
  
  <p>Any idea how I can avoid this error? Also, when I pass the same input with quotes directly it works fine.</p>