UrlEncode 会把对象的大写转成小写
Dictionary<string, object> pairs = new Dictionary<string, object>() { { "bookId",2}, { "virtualQuantity","10"} }; var json = Newtonsoft.Json.JsonConvert.SerializeObject(pairs); var sd = StortJson(json); List<string> vs = new List<string>(); vs.Add("aqsMyu8x"); vs.Add("123AK"); vs.Add("123456"); vs.Add("1653721579"); vs.Add(sd); vs.Sort(StringComparer.Ordinal); //join string strJoin = string.Join(string.Empty, vs); //UrlEncode var strEncode = HttpUtility.UrlEncode(strJoin); //UrlEncode 会把对象的大写转成小写... 文档:123456123AK1653721579aqsMyu8x{"virtualQuantity":"10","bookId":2} 代码:123456123AK1653721579aqsMyu8x{"virtualQuantity":"10","bookId":2} strEncode:123456123AK1653721579aqsMyu8x%7b%22virtualQuantity%22%3a%2210%22%2c%22bookId%22%3a2%7d 文档: 123456123AK1653721579aqsMyu8x%7B%22virtualQuantity%22%3A%2210%22%2C%22bookId%22%3A2%7D UrlEncode这个方法要重写一下: public static string UrlEncode(string str) { str = HttpUtility.UrlEncode(str); byte[] buf = Encoding.ASCII.GetBytes(str); for (int i = 0; i < buf.Length; i++) { if (buf[i] == '%') { if (buf[i + 1] >= 'a') buf[i + 1] -= 32; if (buf[i + 2] >= 'a') buf[i + 2] -= 32; i += 2; } } return Encoding.ASCII.GetString(buf); }
人各有命,上天注定,有人天生为王,有人落草为寇。脚下的路,如果不是你自己的选择,那么旅程的终点在哪,也没人知道。你会走到哪,会遇到谁,都不一定。