Html5 Json and html5json applications

Source: Internet
Author: User
Tags javascript eval

Html5 Json and html5json applications

This article describes the basic concepts of Json and a small example of assigning values to elements using Json in Html.

What is JSON?
  • JSON refers to the JavaScript Object Notation (JAvaSBytesOBjectNOtation)
  • JSON is a lightweight text data exchange format.
  • JSON is independent of the Language *
  • JSON is self-descriptive and easy to understand.

* JSON uses JavaScript syntax to describe data objects, but JSON is still independent of the language and platform. The JSON parser and JSON library support many different programming languages.

Differences from XML
  • No end tag
  • Shorter
  • Faster read/write speed
  • Ability to parse using the built-in JavaScript eval () method
  • Use Arrays
  • Do not use reserved words
Why use JSON?

For AJAX applications, JSON is easier to use than XML.

JSON syntax rules

JSON syntax is a subset of the syntax of JavaScript Object Notation.

  • Data in name/value pairs
  • Data is separated by commas (,).
  • Brackets save objects
  • Square brackets Save the Array
JSON Value

The JSON value can be:

  • Number (integer or floating point number)
  • String (in double quotation marks)
  • Logical value (true or false)
  • Array (in square brackets)
  • Object (in curly brackets)
  • Null
JSON File
  • The JSON file type is ". json"
  • The MIME type of JSON text is "application/json"

Bytes ---------------------------------------------------------------------------------------------------------

In Html5, Json is used to assign values to elements, including CSS styles and JavaScript scripts. As shown in:

The Code is as follows:

1 <! DOCTYPE html> 2 View Code

 

Related Article

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.