日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

JSON语法介绍

發布時間:2025/3/19 javascript 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JSON语法介绍 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
? 官網:https://www.json.org/ ? ? JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language. 譯: JSON(JavaScript Object Notation)是一種輕量級的數據交換格式。 人類很容易讀寫。 機器很容易解析和生成。 它基于JavaScript編程語言的一個子集,標準ECMA-262第3版 - 1999年12月.JSON是一種完全獨立于語言的文本格式,但使用C語言系列程序員熟悉的約定,包括C語言 ,C ++,C#,Java,JavaScript,Perl,Python等等。 這些屬性使JSON成為理想的數據交換語言。 ? JSON is built on two structures: * A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array. * An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence. 譯: JSON基于兩種結構: 名稱/值對的集合。 在各種語言中,這被實現為對象,記錄,結構,字典,散列表,鍵控列表或關聯數組。 有序的值列表。 在大多數語言中,這被實現為數組,向量,列表或序列。 ? These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangeable with programming languages also be based on these structures. 譯: 這些是通用數據結構。 實際上,所有現代編程語言都以某種形式支持它們。 有意義的是,可與編程語言互換的數據格式也基于這些結構。 ? ? In JSON, they take on these forms: ? 1. An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma). 譯: 在JSON中,他們采用以下形式: ? 對象是一組無序的名稱/值對。 對象以{(左括號)開頭,以}結尾(右括號)。 每個名稱后跟:(冒號),名稱/值對用(逗號)分隔 ? ? 總結:用花括號表示對象,名稱/值對可以有多個,并用逗號分隔 ? 示例: { "firstName":"John" , "lastName":"Doe" } 一個{}就是一個JSONObject ? 2. An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma). 譯: 數組是有序的值集合。 數組以[(左括號)開頭并以]結尾(右括號)。 值以(逗號)分隔 ? 總結:用方括號表示數組,值以逗號分隔 ? 示例: 數組可包含多個對象 { "employees": [ { "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" } ] } ? 說明:employees的值是一個數組,數組的元素是3個對象,每個對象是名稱/值對,3個對象之間以逗號分隔 ? 3. A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested. 譯: 值可以是雙引號中的字符串,數字,或true或false或null,或對象或數組。 這些結構可以嵌套。 ? JSON 值可以是:
  • 數字(整數或浮點數)
  • 字符串(在雙引號中)
  • 邏輯值(true 或 false)
  • 數組(在方括號中)
  • 對象(在花括號中)
  • null
  • JSONObject
  • JSONArray
? 4. A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string. 譯: 字符串是零個或多個Unicode字符的序列,用雙引號括起來,使用反斜杠轉義。 字符表示為單個字符串。 字符串非常類似于C或Java字符串。 ? ? 總結:使用反斜杠轉義。 ? 5. A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used. 譯: 除非不使用八進制和十六進制格式,否則數字非常類似于C或Java編號。 ? ? JSON Vs XML 1.JSON和XML的數據可讀性基本相同 2.JSON和XML同樣擁有豐富的解析手段 3.JSON相對于XML來講,數據的體積小 4.JSON與JavaScript的交互更加方便 5.JSON對數據的描述性比XML較差 6.JSON的速度要遠遠快于XML ? ? ?

轉載于:https://www.cnblogs.com/onelikeone/p/9999768.html

總結

以上是生活随笔為你收集整理的JSON语法介绍的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。