Introduction to JSON

Source: Internet
Author: User
Tags javascript eval

Ylbtech-json:json Introduction

Json:javascript Object Notation (JavaScript object notation) JSON is the syntax for storing and exchanging textual information, similar to XML.

JSON is smaller, faster, and easier to parse than XML.

JSON instance

{"employee": [{"firstName": "John", "LastName": "Doe"},{"firstName": "Anna", "LastName": Smith "},{" firstName ":" Peter "," LastName ":" Jones "}]}

This Employee object contains an array of 3 employee records (objects).

1. What is JSON? back to top
1. JSON refers to JavaScript Object notation (JavaScript objects Notation) 2. JSON is a lightweight text data Interchange Format 3. JSON is independent of language. JSON is self-descriptive and easier to understand
* JSON uses JAVASCRIPT syntax to describe data objects, but JSON is still independent of language and platform. The JSON parser and the JSON library support many different programming languages. Currently very much dynamic (php,jsp,. NET) programming language supports JSON.
2. JSON-Convert to JavaScript object back to top
The JSON text format is syntactically identical to the code that creates the JavaScript object. Because of this similarity, the JavaScript program can use the built-in eval () function to generate native JavaScript objects with JSON data without a parser.
3. The instance returns to the top
3.1 Code
<!DOCTYPE HTML><HTML><Body>    <H2>JSON Object creation in JavaScript</H2>    <P>Name:<spanID= "Jname"></span><BR/>Age :<spanID= "Jage"></span><BR/>Address:<spanID= "Jaddress"></span><BR/>Phone:<spanID= "Jphone"></span><BR/>    </P>    <Script>        varJsonobject= {            "name": "John Johnson",            "Street": "Oslo West 555",            " Age":  -,            "Phone":"555 1234567"        }; document.getElementById ("Jname"). InnerHTML=Jsonobject.name; document.getElementById ("Jage"). InnerHTML=Jsonobject.age; document.getElementById ("jaddress"). InnerHTML=Jsonobject.street; document.getElementById ("Jphone"). InnerHTML=Jsonobject.phone; </Script></Body></HTML>

3.2 Results

3.3
4. Return to the top of the XML same place
1. JSON is plain text 2. JSON has a "self-descriptive" (Human readable) 3. JSON has a hierarchy (values exist in values) 4. JSON can be parsed by JavaScript 5. JSON data can be transmitted using AJAX
5. Back to top with XML differences
1. No end tag 2. A shorter 3. Read and write at a faster rate of 4. The built-in JavaScript eval () method can be used to parse 5. Use array 6. Do not use reserved words
6. Why use JSON? back to top
JSON is faster and easier to use than XML for AJAX applications.
7. Using XML to return to the top
1. Read XML document 2. Use the XML DOM to iterate through document 3. Read the value and store it in a variable
8. Use JSON to return to top
1. Read the JSON string 2. Working with the JSON string with eval ()
9. back to top
back to top
One by one . back to top
Ylbtech
Source: http://ylbtech.cnblogs.com/
This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.

Introduction to JSON

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.