none
jSon format problem RRS feed

  • Question

  • Here is my code in asp.net web api controller

     [Route("~/GetLoginEmployeeInfo")]
            public DataTable GetLoginEmployeeInfo()
            {
                string empID = "20160636";
                string password ="123";
                DataTable dtUserInfo = new DataTable();
                DataTable dtOprating = new DataTable();
                Hashtable ht = new Hashtable();
                ht.Add("LoginKey", empID);
                ht.Add("Passkey", password);

                dtUserInfo = DataTableByCommandFromStoredProc("GetUserByIDAndPass", ht, conCommunity);
                if (dtUserInfo.Rows.Count > 0)
                {
                    ht.Clear();
                    ht.Add("EmployeeID", empID);
                    dtOprating = DataTableByCommandFromStoredProc("AOP_GetOperatingEmpID", ht, conOperating);
                    return dtOprating;

                }
                else
                {
                    return dtUserInfo;
                }

            }

    and in WebApiConfig  i have add

     config.Formatters.Remove(config.Formatters.XmlFormatter);

    Output:

    [{"EmpID":"20160636","FullName":"Delower"}]

    but i want

    {"EmpID":"20160636","FullName":"Delower"} in this format for my programming purpose.

    Please help me.

    Sunday, February 5, 2017 10:43 AM

All replies