JSON learning complete manual with pictures and text_javascript skills
JSON: JavaScript Object Notation
is Javascript (jscript, ECMA Javascript, etc.) describing object data (various metadata are actually the simplest objects) A data structure. The concept and usage are similar to Hash (hash table) or associative array.
JSON is constructed from two structures:
A collection of name/value pairs. In different languages, it is understood as an object, a record, a struct, a dictionary, a hash table, a keyed list, or an associative array. array).
An ordered list of values. In most languages, it is understood as an array.
These are common data structures. In fact most modern computer languages support them in some form. This makes it possible for a data format to be exchanged between programming languages that are also based on these structures.
The simplest JSON example is as follows:
[
{ name:"Michael", email:"17bity@gmail.com", homepage:"http://www.jb51.net" },
{ name:"John", email:"john@gmail.com", homepage:"http://s.jb51.net" },
{ name:"Peggy", email:"peggy@gmail.com" , homepage:"http://tools.jb51.net" }]
The following example describes an email contact list. Running with eval in javascript will get a maillist object. Entity, then you can use javascript for further operations.
var maillist = [
{ name :"Michael", email:"17bity@gmail.com", homepage:"http://www.jb51.net" },
{ name:"John", email:"john@gmail.com", homepage:"http://s.jb51.net" },
{ name:"Peggy", email:"peggy@gmail.com", homepage:"http://tools.jb51.net" }
]
Then you can use javascript for further operations.
Chapter 2 JSON Format
The basic format of JSON is as follows, the picture comes from json.org:
An object is a collection of attribute and value pairs. An object starts with "{" and ends with "}". Use ":" to prompt between each attribute name and value, and use "," to separate attributes.

An array is an ordered collection of values. An array starts with "[" and ends with "]", and the values are separated by ",".

The definition of string is basically the same as C or Java.

The definition of numbers is basically the same as C or Java.

Chapter 3 Using trimpath Template to make JSON templates
Trimpath Template is used to parse Json data and generate web page code lightweight JS code.
Demo: http://demo.jb51.net/js/js_template/test.htm
trimpath.template is based on JavaScript, cross-browser, using APL /GPL open source code agreement, which allows you to easily create a pure JS engine based on template programming.
http://code.google.com/p/trimpath/
It has the following characteristics:
1. Using standard JavaScript Writing, supporting cross-browser
2. Template syntax is similar to: FreeMarker, Velocity, Smarty
3. Use simple language to describe large strings and Dom/DHTML operations
4. It can be very convenient Parses data in XML file format into the specified template.
Using this engine, you can let it completely handle View matters, and the server-side Module can directly output Data. Let your MVC model be integrated, and since the View is processed by the browser, the burden on the server is greatly reduced. It is a very good choice to build network information system applications with Ajax technology.
This is a simple and compact template tool class, used to help users quickly assemble the required strings.
Simple explanation: in the template, between #{ ... /} The data will be executed as a js script, and the VAR keyword represents the value of seed (a changed value passed in from the outside).
The template is divided into two parts for execution, compile and run. #{.. The part between ../} is executed during run, and the part between
#{#...../} is executed during compilation. Seed cannot be passed into the code executed during compilation.
There is no need to write more explanations, because it is indeed a very simple function.
Principle: In fact, it uses the passed parameters to replace the #{ .../} part in the template string .(Execute eval() on the part between #{ .../}, and then replace it).
If you are interested in template technology, you can also learn more by studying the code inspiration.
Summary
As the default data format of JAVASCRIPT, json is very convenient for Ajax operations and is much smaller than XML files. Therefore, it has better performance in situations where the network speed is not ideal and the system coupling degree is relatively high.
But XML, as a self-describing format, has wider applications around the world. Therefore, when the system requires cross-platform and cross-language, XML is still the best choice.

JavaScript is at the heart of modern websites because it enhances the interactivity and dynamicity of web pages. 1) It allows to change content without refreshing the page, 2) manipulate web pages through DOMAPI, 3) support complex interactive effects such as animation and drag-and-drop, 4) optimize performance and best practices to improve user experience.

C and JavaScript achieve interoperability through WebAssembly. 1) C code is compiled into WebAssembly module and introduced into JavaScript environment to enhance computing power. 2) In game development, C handles physics engines and graphics rendering, and JavaScript is responsible for game logic and user interface.

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Atom editor mac version download
The most popular open source editor

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment
