Encrypt unencrypted parameters in a link with JSON object

Source: Internet
Author: User
Tags urlencode

Code:

  protected stringFormaturlencode (stringURL) {            stringresult =string.            Empty; if(URL.) IndexOf ("?") <0)returnresult; stringDomain=url. Split ('?')[0].            ToString (); stringparas = URL. Split ('?')[1].            ToString (); string[] Para = paras. Split ('&'); StringBuilder Strbuilder=NewStringBuilder (); Strbuilder.append (Domain+"?"); foreach(varPainchpara) {                stringName = Pa. Split ('=')[0]; stringValue = Pa. Split ('=')[1]; if(value.) Contains ('[') &&value. Contains (']') &&value. Contains ('{') &&value. Contains ('}'))                {                    stringContent = value. Substring (1, value. Length-2); List<string> list =Newlist<string>(); //You cannot use commas here, because object attributes are also commas                    if(content. Contains ("},{") ) {list= Regex.Split (Content,"},{").                        ToList (); list[0] = list[0]. Substring (1, list[0]. Length-1); intindex = list. Count ()-1; List[index]= List[index]. Substring (0, List[index]. Length-1); }                    Else{list. ADD (content. Substring (1, content. Length-2)); } strbuilder.append (Name+"=["); foreach(varLinchlist) {                        //the L object here is to get rid of the property set of {,}Strbuilder.append ("{"); string[] jsons = L.split (','); foreach(varJinchjsons) {                            //when Val is a link that contains a colon inside, it will have less data                            string[] Vals = J.split (':'); stringKey = J.split (':')[0]; stringval = J.split (':')[1]; //To troubleshoot http://www.baidu.com                            if(Vals. Length >2) {Val= J.substring (key. length+1, J.length-key. length-1); } strbuilder.append (Key+":"+ Httputility.urlencode (val) +","); } Strbuilder= Strbuilder.remove (Strbuilder.length-1,1); Strbuilder.append ("}"); Strbuilder.append (","); } Strbuilder= Strbuilder.remove (Strbuilder.length-1,1); Strbuilder.append ("]&"); }                Else{strbuilder.append (name+"="+ Httputility.urlencode (value) +"&"); }} Strbuilder= Strbuilder.remove (Strbuilder.length-1,1); returnstrbuilder.tostring (); }

Link:

http//www.baidu.com?blabel=&buid=&createTime=2015-01-16 10:02:42&customeraddress=&customercomment =&customermobile=&customername=&orderlist=[{"AgentName": "Ctrip", "Itemamount": 2, "itemId": 3022641, " Itemimgurl ":", "ItemName": "The same process test resource", "Itemorderdetail": "", "Itemorderdetailwap": "", "Itemordertime": "2014-12-10" , "Itemprice": 10000, "Itemurl": "http://piao.ctrip.com/dest/t12.html" ," Itemurlwap ":"http://m.ctrip.com/webapp/ticket/dest/t12.html"}] &ordername=&partnerid=ctrip&payway= Test Products Online Payment &srcorderid=1800000009&status=104&totalamount=11000&key=baidulvyou_wangyonghui

Encrypt unencrypted parameters in a link with JSON object

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.