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