Table of Contents
JSON Introduction
JSON Facts
Use JSON
Storing Arrays in JSON
Difference between JSON and XML
Similarities between XML and JSON
in conclusion
Home Web Front-end JS Tutorial Interesting facts about JSON

Interesting facts about JSON

Sep 09, 2023 pm 04:01 PM

关于 JSON 的有趣事实

JSON stands for JavaScript Object Notation, basically, JSON is often used with JavaScript and it was originally a subset of the JavaScript programming language. However, JSON is a language-independent data format. In this article, we will learn about JSON and its interesting facts through examples.

JSON Introduction

When data can be transmitted and stored in a simple format, it's called JSON, or JavaScript Object Notation. Arrays, objects, name and value pairs, and other data types can all be found in JSON. This format uses quotation marks, square brackets, parentheses, semicolons, and colons as punctuation marks. In JSON, data is represented as name-value pairs, much like JavaScript object properties. JSON is a lightweight data transmission method. Furthermore, this language is described as prototype-based, multi-paradigm, and dynamic. Whenever data is sent from the server to a web page, we need to use JSON.

JSON Facts

Here we will discuss many interesting facts about JSON with explanations and examples. Here are interesting facts about JSON -

  • Originally, JSON was considered a subset of the JavaScript programming language. (Specifically the standard ECMA-262, third edition published in December 1999).

  • JSON is generated by JavaScript, and many programming languages ​​now have code that can be used to call and interpret JSON formatted data. It is a data format that is not language specific. The accepted JSON internet media type is application/JSON. The .json extension is used for JSON file names.

  • Douglas Crockford was the first to define and popularize the JSON format. In April 2001, Douglas Crockford and Chip Morningstar sent the first JSON message.

  • Crockford inserted a phrase into the JSON license stating that "this software should be used for good, not evil." On the other hand, since free software and open source software usually mean no restrictions on the purpose of use, this part leads to licensing compatibility issues of the JSON license with other open source licenses.

  • The syntax of the JSON format is comparable to the syntax of JavaScript object creation code. This allows JavaScript programs to easily convert JSON data into JavaScript objects. JSON data can be used by any programming language, and since it is just a text format, it can be easily transferred between machines.

  • Cartoon Network's Communities.com has a children's digital asset trading game called "Cartoon Orbit" (State's co-founders all worked at the company), using a browser plug-in with Customize the messaging system to change DHTML components. This is the beginning of the JSON library.

  • If the JSON file has syntax problems, the request will usually fail silently. Therefore, JSON data should not be manually edited frequently. The data exchange format JSON has higher syntax requirements than JavaScript's object literal representation. For example, all strings in a JSON representation, whether values ​​or properties, need to be enclosed in double quotes

  • The JSON string is decrypted by JavaScript running in the user's browser, and the product data is displayed on the page.

Use JSON

As we have seen, JSON is an object type in the JavaScript programming language that stores data in the form of string literals, ending with the .json extension. JSON objects store data in key-value format, enclosed in curly braces just like JavaScript objects. Let’s see an example to better understand JSON code -

{
   "key1" : "pair1",
   "key2" : "pair2",
   "key3" : {
      "sub-key1" : "opp_value",
      "sub_key2" : "opp_value",
   },
   "key4" : {
      "sub-key1" : "opp_value",
      "sub_key2" : "opp_value",
   },
   "key5" : "pair5",
}
Copy after login

In the above JSON code, we can see that there are 5 key pairs, where the keys are in the form of simple strings. The key pairs can be strings or other objects, such as arrays, strings, etc. All key pairs are separated by commas and enclosed within curly braces.

Any data can be stored this way and can be passed or shared in a simple way using this format.

Storing Arrays in JSON

We have seen simple code for writing JSON objects, now let us see how users can store arrays in JSON objects -

{
   "key1" : "pair1",
   "key2" : "pair2",
   "key3" : {
      "sub-key1" : "opp_value",
      "sub_key2" : "opp_value",
   },
   "key4" : [
      "sub-key1" : "opp_value",
      "sub_key2" : "opp_value", object1, object2
   ],
   "key5" : "pair5",
}
Copy after login

In the above code, we can see that the fourth key is stored in an array, not another object, which is supported by json.

Difference between JSON and XML

Both JSON and XML are used to store data and share or transfer data, and both are very good in their own league, let’s look at some of the differences between them -

  • Compared to XML, JSON is very easy to learn because it is not used directly.

  • Since JSON is just a straight string containing data in the form of a key pair, it is easy to read and write JavaScript objects, while XML is difficult to read and write

  • JSON is data-oriented and works that way, while XML is document-oriented.

  • JSON is not secure because it is only data-oriented, while XML is quite secure compared to JSON.

  • XML does not support arrays, while JSON provides tools that support arrays.

Similarities between XML and JSON

We've seen some of the differences between JSON and XML, now let's look at some of the things they have in common -

  • Since both XML and JSON contain text that humans can read, they are both self-describing

  • Both JSON and XML support hierarchical organization. When we talk about hierarchies, we mean values ​​contained within values.

  • Data exchange formats Data exchange formats such as JSON and XML are supported by a variety of programming languages.

  • Both formats can be processed quickly and easily.

  • Retrieval: Both forms of data can be retrieved using HTTP requests. Data can be retrieved using GET, PUT, and POST methods.

in conclusion

In this article, we learned about JSON and its interesting facts through examples. JSON stands for JavaScript Object Notation, basically, JSON is often used with JavaScript and it was originally a subset of the JavaScript programming language. Arrays, objects, name and value pairs, and other data types can all be found in JSON. This format uses quotation marks, square brackets, parentheses, semicolons, and colons as punctuation marks.

The above is the detailed content of Interesting facts about JSON. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1261
29
C# Tutorial
1234
24
Demystifying JavaScript: What It Does and Why It Matters Demystifying JavaScript: What It Does and Why It Matters Apr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

The Evolution of JavaScript: Current Trends and Future Prospects The Evolution of JavaScript: Current Trends and Future Prospects Apr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

JavaScript Engines: Comparing Implementations JavaScript Engines: Comparing Implementations Apr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript: Exploring the Versatility of a Web Language JavaScript: Exploring the Versatility of a Web Language Apr 11, 2025 am 12:01 AM

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration) How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration) Apr 11, 2025 am 08:22 AM

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

Python vs. JavaScript: The Learning Curve and Ease of Use Python vs. JavaScript: The Learning Curve and Ease of Use Apr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

From C/C   to JavaScript: How It All Works From C/C to JavaScript: How It All Works Apr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Building a Multi-Tenant SaaS Application with Next.js (Backend Integration) Building a Multi-Tenant SaaS Application with Next.js (Backend Integration) Apr 11, 2025 am 08:23 AM

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

See all articles