json_json的定义/definition of json

2022/1/29 6:07:41

本文主要是介绍json_json的定义/definition of json,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Json definition

权威定义

  • JSON(json.org)
  • JSON中文
  • JSON - MDN Web Docs Glossary: Definitions of Web-related terms | MDN (mozilla.org)
  • JSON - JavaScript | MDN (mozilla.org)
  • JSON - Wikipedia

其他资料

  • JSON Schema 参考书 - 云+社区 - 腾讯云 (tencent.com)
  • 使用JSON - 学习 Web 开发 | MDN (mozilla.org)

json基本特点

JSON is purely a string with a specified data format — it contains only properties, no methods.

JSON requires double quotes to be used around strings and property names.

  • Single quotes are not valid other than surrounding the entire JSON string.

Even a single misplaced comma or colon can cause a JSON file to go wrong, and not work.

  • You should be careful to validate any data you are attempting to use (although computer-generated JSON is less likely to include errors, as long as the generator program is working correctly). You can validate JSON using an application like JSONLint.

JSON can actually take the form of any data type that is valid for inclusion inside JSON, not just arrays or objects.

  • So for example, a single string or number would be valid JSON.(这种情况下用处不大)

Unlike in JavaScript code in which object properties may be unquoted, in JSON only quoted strings may be used as properties.

Data types

JSON’s basic data types are:

  • Number: a signed decimal number that may contain a fractional part and may use exponential E notation, but cannot include non-numbers such as NaN. The format makes no distinction between integer and floating-point. JavaScript uses a double-precision floating-point format for all its numeric values (until later also supports BigInt[24]), but other languages implementing JSON may encode numbers differently.
  • String: a sequence of zero or more Unicode characters. Strings are delimited with double-quotation marks and support a backslash escaping syntax.
  • Boolean: either of the values true or false
  • Array: an ordered list of zero or more elements, each of which may be of any type. Arrays use square bracket notation with comma-separated elements.
  • Object: a collection of name–value pairs where the names (also called keys) are strings. The current ECMA standard states: “The JSON syntax does not impose any restrictions on the strings used as names, does not require that name strings be unique, and does not assign any significance to the ordering of name/value pairs.”[25] Objects are delimited with curly brackets and use commas to separate each pair, while within each pair the colon ‘:’ character separates the key or name from its value.
  • null: an empty value, using the word null


这篇关于json_json的定义/definition of json的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程