在读取post中body的参数转换成JSON字符串
private string getDataValueToPT()
{
StreamReader reader = new StreamReader(Request.InputStream);
string indata = reader.ReadToEnd();
if (string.IsNullOrEmpty(indata))
{
return "";
}
//ypdm = &yplx = &page = 1 & percount = 20
//{ "ypdm":"","yplx":"","page":"1","percount":"20"}
string outdata = "";
try
{
List<string> list = new List<string>();
string[] _noteList = indata.Split('&');
foreach (string item in _noteList)
{
string itemnew = "\"" + item;
itemnew = itemnew.Insert(itemnew.IndexOf('='), "\"") + "\"";
list.Add(itemnew);
}
outdata = "{" + string.Join(",", list.Distinct()).Replace("=", ":\"") + "}";
}
catch
{
return "";
}
return outdata;
}