Click here to Skip to main content
15,921,371 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have written a WCF REST service.My Get method would return a list values..When I execute my xml response is :
<GetAppointmentList xmlns:i="">

How ever when I tried the same with JSON response Iam getting like :
bf98bd3b-dccc-442d-ab4b-0bad4ecbdfd7Care919 12:0013:00 10
i.e JSON response is not clear..I want the response in
"AppointmentEndTime":"19 ",

How can I get a clear response like this in JSON format?
I am using this code:
       [WebInvoke(UriTemplate = "GetAppointments/?companyId={companyId}&appointmentDate={appointmentDate}", Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
     GetAppointmentList GetAppointment(Guid companyId, string appointmentDate);

Service1.cs :
public GetAppointmentList GetAppointment(Guid companyId, string appointmentDate)
            SQLDataContext context = new SQLDataContext();

            var getappointment = context.GetAppointmentTimings(companyId,appointmentDate);
           GetAppointmentList getappointmentlist = new GetAppointmentList();

            getappointmentlist.AppointmentList = new List<company>().ToList();
            foreach (var r in getappointment.ToList())
                Company company = new Company();
                company.CompanyId = r.CompanyId;
                company.CompanyName = r.CompanyName;
                company.BreakStartTime = r.BreakStartTime + ":" + "00";
                company.BreakEndTime = r.BreakEndTime + ":" + "00";
                company.Interval = r.Interval;
                company.AppointmentStartTime = r.AppointmentStartTime;
                company.AppointmentEndTime = r.AppointmentEndTime;
    return getappointmentlist;

Updated 7-Sep-12 22:42pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900