Ejemplo n.º 1
0
        /// <summary>
        /// 替换jsonData中的key对应数据为newValue
        /// </summary>
        /// <param name="jsonData"></param>
        /// <param name="key"></param>
        /// <param name="newValue"></param>
        /// <returns></returns>
        public static String ReplaceJsonValue(String jsonData, String key, String newValue)
        {
            String value     = ScTool.getJsonValue(jsonData, key);
            String valueStr  = "\"HbUrl\":\"" + value + "\"";
            String valueStr2 = "\"HbUrl\":" + value;

            if (jsonData.Contains(valueStr))
            {
                String valueStrNew = "\"HbUrl\":\"" + newValue + "\"";
                jsonData = jsonData.Replace(valueStr, valueStrNew);
            }
            else if (jsonData.Contains(valueStr2))
            {
                String valueStrNew = "\"HbUrl\":" + newValue;
                jsonData = jsonData.Replace(valueStr2, valueStrNew);
            }

            return(jsonData);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 解析参数字符串为Dicnary数据;
        /// 如:machinCode=机器码1&soft=easyIcon软件&product=注册0.1元
        /// </summary>
        /// <param name="StaticParam">参数字符串信息</param>
        /// <returns></returns>
        public static Dictionary <string, string> ToParamsDic(string StaticParam)
        {
            Dictionary <string, string> pramsDic = new Dictionary <string, string>();

            if (StaticParam.Contains("&"))
            {
                string[] A = StaticParam.Split('&');

                foreach (string a in A)
                {
                    if (a.Contains("="))
                    {
                        string[] B = ScTool.splitTwo(a, "=");
                        pramsDic.Add(B[0], B[1]);
                    }
                }
            }

            return(pramsDic);
        }