Using the Generic Dictionary with JSON web services…
If you want to pass a name/value collection of untyped data to a webservice with JSON, do it like this guys, Joost van Schaik, says:
http://dotnetbyexample.blogspot.com/2008/03/json-services-revisited-using.html
Here’s the meat of it really – how do you initialize the Dictionary object as a parameter?
Check it out – this is from the blog entry, but basically you just load the object up with values using strings as indexes, and you’re rocking.
<script type="text/javascript"> function LoadDict() { var dict = new Object(); dict["test1"] = "Joost"; dict["test2"] = 21; dict["test3"] = true; dict["test4"] = 9999999999; dict["test5"] = new Date(2008,09,12,13,14,00); DictService.DictMethod( dict, ProcessResult ); } function ProcessResult( WebServiceResult ) { document.write( WebServiceResult ); } </script>
The data types are interpretted by .net on the server side, and usually make sense (21 becomes an int, the Date becomes a DateTime etc).
More later - joel