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

Published Tuesday, April 28, 2009 10:24 AM by joelvarty
Filed under: , , ,

Comments

# re: Using the Generic Dictionary with JSON web services…

Thursday, June 11, 2009 10:09 AM by Joost van Schaik

I thank thee for noticing my existence ;-)

Joost

# Using the Generic Dictionary with JSON web services??? | OOP - Object Oriented Programing

Pingback from  Using the Generic Dictionary with JSON web services??? | OOP - Object Oriented Programing

Leave a Comment

(required) 
(required) 
(optional)
(required)