Posted on 2007-09-20 21:55
semovy 閱讀(404)
評論(0) 編輯 收藏 所屬分類:
JSON
 |
介紹 JSON
|
- object
- {}
{ members }
-
- members
- pair
pair , members
- pair
- string : value
- array
- []
[ elements ]
- elements
- value
value , elements
- value
- string
number
object
array
true
false
null
- string
- ""
" chars "
- chars
- char
char chars
- char
- any-Unicode-character-
except-"-or-\-or-
control-character
\"
\\
\/
\b
\f
\n
\r
\t
\u four-hex-digits
- number
- int
int frac
int exp
int frac exp
- int
- digit
digit1-9 digits
- digit
- digit1-9 digits
- frac
- . digits
- exp
- e digits
- digits
- digit
digit digits
- e
- e
e+
e-
E
E+
E-
JSON(JavaScript Object Notation) 是一種輕量級的數據交換格式。易于人閱讀和編寫。同時也易于機器解析和生成。它基于JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999的一個子集。 JSON采用完全獨立于語言的文本格式,但是也使用了類似于C語言家族的習慣(包括C, C++, C#, Java, JavaScript, Perl, Python等)。這些特性使JSON成為理想的數據交換語言。
JSON建構于兩種結構:
- “名稱/值”對的集合(A collection of name/value pairs)。不同的語言中,它被理解為對象(object),紀錄(record),結構(struct),字典(dictionary),哈希表(hash table),有鍵列表(keyed list),或者關聯數組 (associative array)。
- 值的有序列表(An ordered list of values)。在大部分語言中,它被理解為數組(array)。
這些都是常見的數據結構。事實上大部分現代計算機語言都以某種形式支持它們。這使得一種數據格式在同樣基于這些結構的編程語言之間交換成為可能。
JSON具有以下這些形式:
對象是一個無序的“‘名稱/值’對”集合。一個對象以“{”(左括號)開始,“}”(右括號)結束。每個“名稱”后跟一個“:”(冒號);“‘名稱/值’ 對”之間使用“,”(逗號)分隔。

數組是值(value)的有序集合。一個數組以“[”(左中括號)開始,“]”(右中括號)結束。值之間使用“,”(逗號)分隔。

值(value)可以是雙引號括起來的字符串(string)、數值(number)、true
、false
、 null
、對象(object)或者數組(array)。這些結構可以嵌套。

字符串(string)是由雙引號包圍的任意數量Unicode字符的集合,使用反斜線轉義。一個字符(character)即一個單獨的字符串(character string)。
字符串(string)與C或者Java的字符串非常相似。

數值(number)也與C或者Java的數值非常相似。除去未曾使用的八進制與十六進制格式。除去一些編碼細節(jié)。

空白可以加入到任何符號之間。 以下描述了完整的語言。
- ASP.
- ActionScript:
- C.
- C++:
- C#:
- Cold Fusion:
- D.
- Delphi:
- E.
- haXe.
Why JSON isn't just for JavaScript • I can't believe it's not XML! • The JSON vs XML debate begins in earnest • JSON and XML • Why JSON vs XML is a yawn • JSON vs. XML as a data interchange format • Examining JSON • JSON and .Net • An Introduction to JSON • Shaping the future of secure Ajax mashups • JSON and Browser Security
json@JSON.org