Example #1
0
        /// <summary>
        /// json数据包装成数据结构
        /// </summary>
        /// <param name="rootData">json数据</param>
        /// <returns></returns>
        IServerResponseData ParseJsonToStructData(JObject rootData)
        {
            IServerResponseData objServerResponseData = new ServerResponseData();

            JProperty jPropertyCode   = null;
            JProperty jPropertyMsg    = null;
            JProperty jPropertyUpdate = null;
            JProperty jPropertyGmt    = null;

            foreach (JProperty jPropertyRootItem in rootData.Children())
            {
                if (SERVER_RESPONSE_CODE == jPropertyRootItem.Name)
                {
                    jPropertyCode = jPropertyRootItem;
                }
                else if (SERVER_RESPONSE_MSG == jPropertyRootItem.Name)
                {
                    jPropertyMsg = jPropertyRootItem;
                }
                else if (SERVER_RESPONSE_UPDATE == jPropertyRootItem.Name)
                {
                    jPropertyUpdate = jPropertyRootItem;
                }
                else if (SERVER_RESPONSE_GMT == jPropertyRootItem.Name)
                {
                    jPropertyGmt = jPropertyRootItem;
                }
            }

            if (jPropertyCode != null)
            {
                objServerResponseData.code       = ParseCode(jPropertyCode);
                objServerResponseData.serverTime = long.Parse(jPropertyGmt.Value.ToString());
                if (0 == objServerResponseData.code)
                {
                    if (jPropertyMsg != null)
                    {
                        objServerResponseData.msgListData = ParseMsg(jPropertyMsg);
                    }

                    if (jPropertyUpdate != null)
                    {
                        objServerResponseData.updateListData = ParseUpdate(jPropertyUpdate);
                    }
                }
                else
                {
                    if (jPropertyMsg != null)
                    {
                        objServerResponseData.errMsg = jPropertyMsg.Value.ToString();
                    }
                }
            }

            return(objServerResponseData);
        }
Example #2
0
        /// <summary>
        /// json数据包装成数据结构
        /// </summary>
        /// <param name="rootData">json数据</param>
        /// <returns></returns>
        IServerResponseData ParseJsonToStructData(JObject rootData)
        {
            IServerResponseData objServerResponseData = new ServerResponseData();

            JProperty jPropertyCode = null;
            JProperty jPropertyMsg = null;
            JProperty jPropertyUpdate = null;
            JProperty jPropertyGmt = null;
            foreach (JProperty jPropertyRootItem in rootData.Children())
            {
                if (SERVER_RESPONSE_CODE == jPropertyRootItem.Name)
                {
                    jPropertyCode = jPropertyRootItem;
                }
                else if (SERVER_RESPONSE_MSG == jPropertyRootItem.Name)
                {
                    jPropertyMsg = jPropertyRootItem;
                }
                else if (SERVER_RESPONSE_UPDATE == jPropertyRootItem.Name)
                {
                    jPropertyUpdate = jPropertyRootItem;
                }
                else if (SERVER_RESPONSE_GMT == jPropertyRootItem.Name)
                {
                    jPropertyGmt = jPropertyRootItem;
                }
            }

            if (jPropertyCode != null)
            {
                objServerResponseData.code = ParseCode(jPropertyCode);
                objServerResponseData.serverTime = long.Parse(jPropertyGmt.Value.ToString());
                if (0 == objServerResponseData.code)
                {
                    if (jPropertyMsg != null)
                    {
                        objServerResponseData.msgListData = ParseMsg(jPropertyMsg);
                    }

                    if (jPropertyUpdate != null)
                    {
                        objServerResponseData.updateListData = ParseUpdate(jPropertyUpdate);
                    }

                }
                else
                {
                    if (jPropertyMsg != null)
                    {
                        objServerResponseData.errMsg = jPropertyMsg.Value.ToString();
                    }
                }
            }

            return objServerResponseData;
        }