I have very ususual situation where I have WCF service on which I have added REST endpoint and returning JSON data to angular app. My response object is defined in Pascal Case but I would like to return the JSON response in camelCase. Is there anyway to do this in WCF?
I did not have an option to create new Web Api or MVC app where I can do this easily using options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
Here is my code:
WCF Rest Endpoint
IFormsConfigTool.cs
[ServiceContract]
public interface IFormsConfigTool
{
[OperationContract]
[System.ServiceModel.Web.WebInvoke(
Method = "GET",
RequestFormat = System.ServiceModel.Web.WebMessageFormat.Json,
ResponseFormat = System.ServiceModel.Web.WebMessageFormat.Json,
BodyStyle = System.ServiceModel.Web.WebMessageBodyStyle.Bare,
UriTemplate = "getPackageConfig/{superBranch}")]
PackageConfigResponse getPackageConfig(string superBranch);
}
Response Class
public class PackageConfigResponse
{
#region Properties
public List<Package> Packages { get; set; }
public MessageInfo Messages { get; set; }
#endregion Properties
}
Current JSON response enter image description here
Expected JSON response enter image description here