I am newbie to C# and WCF.
I have already gone through this link. But cannot solve.
Following is just a sample GET service method.
Expected JSON format is
{"result":"Hello","add":4}
Result JSON format is
{"GetDataResult":{"add":4,"result":"Hello"}}
Entity class is
[ServiceContract]
public interface IConnectDBService
{
[OperationContract]
[WebInvoke(Method = "GET",
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "val",
ResponseFormat = WebMessageFormat.Json)]
MyObject GetData();
}
[DataContract]
public class MyObject
{
[DataMember(Name = "result")]
public string result { get; set; }
[DataMember(Name = "add")]
public int add { get; set; }
}
Service class is
public MyObject GetData()
{
return new MyObject { result = "Hello", add = 4 };
}
How do I eliminate "GetDataResult" from result. And notice that key's are sorted alphabetically in the resulted JSON. Any suggestion to format JSON in our vision.
Thank You