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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

How do I create and publish my own JavaScript libraries? How do I create and publish my own JavaScript libraries? Mar 18, 2025 pm 03:12 PM

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

How do I optimize JavaScript code for performance in the browser? How do I optimize JavaScript code for performance in the browser? Mar 18, 2025 pm 03:14 PM

The article discusses strategies for optimizing JavaScript performance in browsers, focusing on reducing execution time and minimizing impact on page load speed.

What should I do if I encounter garbled code printing for front-end thermal paper receipts? What should I do if I encounter garbled code printing for front-end thermal paper receipts? Apr 04, 2025 pm 02:42 PM

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

Who gets paid more Python or JavaScript? Who gets paid more Python or JavaScript? Apr 04, 2025 am 12:09 AM

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

How do I debug JavaScript code effectively using browser developer tools? How do I debug JavaScript code effectively using browser developer tools? Mar 18, 2025 pm 03:16 PM

The article discusses effective JavaScript debugging using browser developer tools, focusing on setting breakpoints, using the console, and analyzing performance.

How do I use source maps to debug minified JavaScript code? How do I use source maps to debug minified JavaScript code? Mar 18, 2025 pm 03:17 PM

The article explains how to use source maps to debug minified JavaScript by mapping it back to the original code. It discusses enabling source maps, setting breakpoints, and using tools like Chrome DevTools and Webpack.

How to merge array elements with the same ID into one object using JavaScript? How to merge array elements with the same ID into one object using JavaScript? Apr 04, 2025 pm 05:09 PM

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

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.

See all articles