JSON에서 DataTable로 변환

JsonToDataTable
        private void JsonToDatable(JObject pJObject, DataTable dataTable)
        {
            try
            {
                if (pJObject != null && pJObject.Count != 0)
                {
                    DataRow pRow = dataTable.NewRow();
                    pRow[m_sLoginName] = pJObject["userName"].ToString();
                    pRow[m_sUserName] = pJObject["userName"].ToString();
                    pRow[m_sEMail] = pJObject["email"].ToString();
                    pRow[m_sPhone] = pJObject["tellPhone"].ToString();
                    pRow[m_sAddress] = pJObject["address"].ToString();

                    switch (pJObject["type"].ToString())
                    {
                        case "0":
                            pRow[m_sUserType] = "    ";
                            break;
                        case "1":
                            pRow[m_sUserType] = "   ";
                            break;
                        case "2":
                            pRow[m_sUserType] = "     ";
                            break;
                        case "3":
                            pRow[m_sUserType] = "    ";
                            break;
                    }

                    JObject jObject = JObject.Parse(pJObject["orgData"].ToString());
                    string sOrganizition = jObject["name"].ToString();
                    pRow[m_sOrganizition] = sOrganizition;
                    dataTable.Rows.Add(pRow);
                }
            }
            catch { }
        }

좋은 웹페이지 즐겨찾기