标签:
private string urlParamManager(JObject postArray, bool flag) { ArrayList keys = new ArrayList(); foreach (JToken child in postArray.Children()) { JProperty property = child as JProperty; if (flag) { if (!"signMethod".Equals(property.Name) && !"signature".Equals(property.Name)) { keys.Add(property.Name); } } else { keys.Add(property.Name); } } keys.Sort(); StringBuilder sb = new StringBuilder(); foreach (string key in keys) { if (flag) { if (!string.IsNullOrEmpty(postArray[key].Value<string>())) { if (string.IsNullOrEmpty(sb.ToString())) { sb.Append(key + "=" + postArray[key].Value<string>()); } else { sb.Append("&" + key + "=" + postArray[key].Value<string>()); } } } else { if (string.IsNullOrEmpty(sb.ToString())) { sb.Append(key + "=" + postArray[key].Value<string>()); } else { sb.Append("&" + key + "=" + postArray[key].Value<string>()); } } } return sb.ToString(); }
调用方式:
JObject param = new JObject(); param["transaction"] = transaction; param["payType"] = payType; param["userId"] = userId; string paramStr = this.urlParamManager(param, true);
标签:
原文地址:http://www.cnblogs.com/yonguibe/p/4448326.html