title: How to send a hashtable to an asmx webservice?
body: <p>I'm trying to send a hashtable to my webservice using JSON. However, you can't send a dictionary-type object (for some reason).</p>
  
  <p>A solution that apparently works is "List(Of KeyValuePair(Of String, String))", as output anyway:</p>
  
  <pre><code>&lt;WebMethod()&gt; _
  Public Function test() As List(Of KeyValuePair(Of String, String))
      Dim ret As New List(Of KeyValuePair(Of String, String))
      ret.Add(New KeyValuePair(Of String, String)("foo", "5"))
      ret.Add(New KeyValuePair(Of String, String)("bar", "baz"))
      Return ret
  End Function
  </code></pre>
  
  <p>Outputs (in json): [{"Key":"foo","Value":"5"},{"Key":"bar","Value":"baz"}]</p>
  
  <p>When I want to resubmit this in javascript, I have to use this function:</p>
  
  <pre><code>&lt;WebMethod()&gt; _
  Public Sub test2(ByVal obj As List(Of KeyValuePair(Of String, String)))
      Dim dummy As UInt16 = obj.Count
  End Sub
  </code></pre>
  
  <p>I call it using this as JSON parameter string:</p>
  
  <pre><code>'{"obj": [{"Key":"foo","Value":"5"},{"Key":"bar","Value":"baz"}]}'
  </code></pre>
  
  <p>This returns in an error. Not an error per se, but the contents of 'obj' is a list that contains 2 items, but when I look at them in the debugger, both are Nothing (or null for you C# people).</p>
  
  <p>How can I send paired data from javascript to my webservice?</p>