Convert the webpage jump string to JSON format

Source: Internet
Author: User
Tags string to json

When you create a website, a page transmits values to another page through the address. After receiving the page value, you need to convert the data into a JSON object.
Because jquery is used, a method in jquery is used at the beginning.

VaR info = jquery. parsejson (Request ("info "));

In ie, the webpage runs normally, but in Firefox and Google browsers, errors may occur.
I had to use the js method. I tried two methods:

1: var info = eval ("(" + decodeuricomponent (Request ("info") + "); // note that the decodeuricomponent () method is required for encoding and conversion. 2: vaR info = (new function ("", "Return" + decodeuricomponent (Request ("info") (); // fewer and fewer people use this method, // note that the decodeuricomponent () method is also required for encoding conversion.

Note:
The decodeuricomponent () function can decode the uri of the encodeuricomponent () function.

<SCRIPT type = "text/JavaScript"> var test1 = "http://www.w3school.com.cn/My first/" document. write (encodeuricomponent (test1) + "<br/>") document. write (decodeuricomponent (test1) </SCRIPT>

 

Output:

HTTP % 3A % 2f % 2fwww.w3school.com.cn % 2fmy % 20 first % 2 fhttp: // www.w3school.com.cn/my first/

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.