Briefly, JSON and JSONP.

Source: Internet
Author: User
Tags javascript eval

JSON and JSONP, but from the abbreviation, may think they are very similar to the two nouns, but they are similar in addition to abbreviations, they are two kinds of concepts.

First of all:

  JSON(JAvaScript Object Notation), or JavaScript Object notation, is a lightweight data interchange format that Note: JSON is a data format, which is used to save data,

JSONP (json with Padding) is a "usage pattern" of JSON that can be used to solve the problem of cross-domain data access for mainstream browsers, which is an unofficial cross-domain data interaction protocol.

  For example: We take the recent fire of the spy war film to make an analogy, JSON is used to write and exchange information of the Underground "code", and Jsonp is to use the secret code written by the message to their comrades using the joint method. Did you see that? One is the format of describing information, and the other is the method agreed by both parties to the information delivery.

Second: Here's a bit of JSON alone.

Features of JSON:

JSON is the syntax for storing and exchanging textual information. Similar to XML.

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

Like XML
    • JSON is plain text
    • JSON has a "self-descriptive" (Human readable)
    • 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
    • Even shorter
    • Read and write faster
    • Ability to parse using the built-in JavaScript eval () method
    • Working with arrays
    • Do not use reserved words

JSON Syntax rules

JSON syntax is a subset of the JavaScript object notation syntax.

    • Data in name/value pairs
    • Data is separated by commas
    • Curly braces Save Object
    • Square brackets Save Array

Needless to say, use a simple example to illustrate the JSON format:

This defines a number of friend information, array name: Goodfriends, containing three objects (the contents of curly braces), each object has three properties (Name,hobby,age)

var goodfriends=[         {               "name": "Tom",              "hobby": "Running",                 "age": +            },         {               "name": "John",              "hobby": "Laughing",              "age": +            },         {               "name": "divID",              "hobby": "Badminton",              "age" :            },   ]                        

 

Briefly, JSON and JSONP.

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.