tags:

views:

35

answers:

1

Hi, I want to know if by default the WCF web services return JSon data. and if no how can i configure the most simple WCF web service it to return Json.

thanks in advance.

A: 

The easiest way I know is to create the WCF service in VS (I have VS 2008) with the "AJAX-enabled WCF service" template. It will give you boilerplate code for a JSON-enabled WCF service.

The objects that it takes as arguments and returns must be marked with the [DataContract] attribute, and each property that you want to include in the JSON serialization should be marked with [DataMember] and should have a getter and a setter (even if the setter does nothing).

http://msdn.microsoft.com/en-us/library/bb924552.aspx

Nate C-K
thank you, that info was good. i also read the link you sent and it was very good tutorial. now i just have to make it work for JQuery. thanks.
Cecile
Glad I could help!
Nate C-K