JSON介绍

JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。 易于人阅读和编写。同时也易于机器解析和生成。 它基于JavaScript Programming LanguageStandard 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)、truefalse、 null、对象(object)或者数组(array)。这些结构可以嵌套。


字符串(string)是由双引号包围的任意数量Unicode字符的集合,使用反斜线转义。一个字符(character)即一个单独的字符串(character string)。

字符串(string)与C或者Java的字符串非常相似。


数值(number)也与C或者Java的数值非常相似。除去未曾使用的八进制与十六进制格式。除去一些编码细节。


空白可以加入到任何符号之间。

The JSON data interchange format is easily supported in JavaFree source code is availableIt is provided without support or warranty. Use at your own risk. Please do not use it for evil. Feedback is welcome. Thank you.

Source Javadoc Description
JSONObject.java JSONObject.htmlJSONObject is an unordered collection of name/value pairs. Its external form is a string wrapped in curly braces with colons between the names and values, and commas between the values and names. The internal form is an object having get() and opt()methods for accessing the values by name, and put() methods for adding or replacing values by name. The values can be any of these types: BooleanJSONArrayJSONObjectNumber, and String, or the JSONObject.NULL object.
JSONArray.java JSONArray.htmlJSONArray is an ordered sequence of values. Its external form is a string wrapped in square brackets with commas between the values. The internal form is an object having get() and opt() methods for accessing the values by index, and put() methods for adding or replacing values. The values can be any of these types: BooleanJSONArrayJSONObjectNumber, and String, or theJSONObject.NULL object.
JSONStringer.java JSONStringer.htmlJSONStringer is a tool for rapidly producing JSON text.
JSONWriter.java JSONWriter.htmlJSONWriter is a tool for rapidly writing JSON text to streams.
JSONTokener.java JSONTokener.htmlJSONTokener takes a source string and extracts characters and tokens from it. It is used by the JSONObject and JSONArrayconstructors to parse JSON source strings.
JSONException.java JSONException.htmlJSONException is thrown when a syntax or procedural error is detected.
JSONString.java JSONString.html The JSONString is an interface that allows classes to implement their JSON serialization.
JSON can also be used as a data interchange format between other data interchange formats.
CDL.java CDL.html This provides static methods to convert comma delimited list text into a JSONArray, and to covert a JSONArray into comma delimited list text. Comma delimited list text is a very popular format for data interchange. It is understood by most database, spreadsheet, and organizer programs.
XML.java XML.html This provides static methods to convert an XML text into a JSONObject, and to covert a JSONObject into an XML text.
JSONML.java JSONML.html This provides static methods to convert an XML text into a JSONArray or JSONObject, and to covert a JSONArray or JSONObject into an XML text using the JsonML transform.
XMLTokener.java XMLTokener.html The XMLTokener extends the JSONTokener to provide additional methods for the parsing of XML texts.
HTTP.java HTTP.html Convert an HTTP header to a JSONObject and back.
HTTPTokener.java HTTPTokener.html The HTTPTokener extends the JSONTokener to provide additional methods for the parsing of HTTP headers.
Cookie.java Cookie.html Convert a web browser cookie specification to a JSON object and back.
CookieList.java CookieList.html Convert a web browser cookie list string to a JSON object and back.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值