I'm trying to send a hashtable to my webservice using JSON. However, you can't send a dictionary-type object (for some reason).
A solution that apparently works is "List(Of KeyValuePair(Of String, String))", as output anyway:
<WebMethod()> _
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
Outputs (in json): [{"Key":"foo","Value":"5"},{"Key":"bar","Value":"baz"}]
When I want to resubmit this in javascript, I have to use this function:
<WebMethod()> _
Public Sub test2(ByVal obj As List(Of KeyValuePair(Of String, String)))
Dim dummy As UInt16 = obj.Count
End Sub
I call it using this as JSON parameter string:
'{"obj": [{"Key":"foo","Value":"5"},{"Key":"bar","Value":"baz"}]}'
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).
How can I send paired data from javascript to my webservice?