How do I finish learning JSON in 1 hours?

Source: Internet
Author: User

W3school

↑↑↑ Learn this, 1 hours is enough. Here is an excerpt:

code Example 1:

12<body>34 5<p>6Name: <span id= "Jname"></span><br/>7Age: <span id= "Jage"></span><br/>8Address: <span id= "Jstreet"></span><br/>9Phone: <span id= "Jphone"></span><br/>Ten</p> One  A<script type= "Text/javascript" > - var jsonobject= {"name": "Bill Gates", "Street": "Fifth Avenue New York 666", "Age": 56,17 "Phone": "555 1234567"};←js On can be parsed by JavaScript.  -document.getElementById ("Jname"). innerhtml=Jsonobject.name +document.getElementById ("Jage"). innerhtml=Jsonobject.age -document.getElementById ("Jstreet"). innerhtml=Jsonobject.street +document.getElementById ("Jphone"). innerhtml=Jsonobject.phone A</script> at  -</body> -

code Example 2:

12<body>34<p>5First Name: <span id= "fname"></span><br/>6Last Name: <span id= "lname"></span><br/>7</p>8<script type= "Text/javascript" >9 var txt = ' {' Employees ': [' +10 ' {' firstName ': ' Bill ', ' lastName ': ' Gates '}, ' +11 ' {' firstName ': ' George ', ' lastName ': ' Bush "}, ' +12 ' {" FirstName ":" Thomas "," LastName ":" Carter "}]} '; -  - var obj = eval ("(" + txt + ")"); the ←javascript program can use the built-in eval () function to generate native JavaScript objects with JSON data.  the  -document.getElementById ("fname"). innerhtml=obj.employees[1]. firstName  -document.getElementById ("lname"). innerhtml=obj.employees[1]. lastName  -</script> +</body> -

"Memory Point"

    • The file type of the JSON file is ". JSON"
    • The MIME type of JSON text is "Application/json"
    • The JavaScript program can use the built-in eval () function to generate native JavaScript objects with JSON data.
    • JSON can be parsed by JavaScript.
    • One of the most common uses of JSON is to read the JSON data (as a file or as a HttpRequest) from the Web server, convert the JSON data to a JavaScript object, and then use that data in the Web page.
    • Using the JSON parser to convert JSON to JavaScript objects is a safer practice. The JSON parser only recognizes JSON text and does not compile the script.
    • Native JSON support is included in newer browsers and the latest ECMAScript (JavaScript) standards.
Like XML
    • JSON is plain text
    • JSON has a hierarchy (values exist in values)
    • JSON can be parsed with JavaScript
    • JSON data can be transmitted using AJAX
Compared to the difference between XML
    • No end tag
    • Ability to parse using the built-in JavaScript eval() method
    • Working with arrays
    • Do not use reserved words

How do I finish learning JSON in 1 hours?

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.