url参数转json,先转为键值对,再转json 需要用到Newtonsoft.Json
public string ConvertJson(string str)
{
Dictionary<string, string> dic = new Dictionary<string, string>();
Regex re = new Regex(@"(^|&)?(\w+)=([^&]+)(&|$)?", RegexOptions.Compiled);
MatchCollection mc = re.Matches(str);
foreach (Match m in mc)
{
dic.Add(m.Result("$2"), m.Result("$3"));
}
string json = JsonConvert.SerializeObject(dic);
return json;
}