What is JSON and what to do with it

Source: Internet
Author: User
Tags convert string to json string to json

JSON is a string used to transfer data, involving how to turn JS into a JSON string: stringify () converts a JSON string into a js:parse () and a eval_r () difference between the parse and eval: eval: Can parse any string into JS (will also parse the embedded Trojan) Parse: Only parse the JSON form of the string into JS and attributes in the string are strictly quoted (security is higher)
Eval: How to convert a string to JSON using  var str= ' function show () {alert (123)} '        //String eval_r (str);                          ,         &NB Sp                  //the string into Jsalert (typeof show);                          ,         &NB sp;//can detect that show is already a function. Show ();                          ,         &NB Sp                  //Can execute Js //parse convert string to JSON   using var str= ' function Show () {alert (123)}        //String json.parse (str);  show ();            //Why don't you play it? This is the difference between parse and eval. Parse: Only parse the JSON form of the string into Js var str1= ' {"name": "Hello"} ';//each attribute is quoted, and Parse is a strict var json = Json.parse (STR1);Convert String to JS//alert (json.name)      //deep copy recursive//stringify: Parse js into strict form JSON string var a={name:{ Age:100}};//jsvar Str=json.stringify (a);//Use the Stringify property of JSON to turn object A into a string//alert (str)//string var b=json.parse (str);// And the string into the object B.name.age=200;//alert (a.name.age)   //ie678 incompatible JSON, need to call json2.js to do compatibility//flavor   Video Name: Object reference

What is JSON and what to do with it

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.