官术网_书友最值得收藏!

XML and JSON

Both XML and JSON are used by web services to represent structured sets of data or objects.

As discussed in previous sections, XML uses a syntax based on tags and properties, and values for those tags; for example, the File menu of an application, can be represented as follows:

<menu id="m_file" value="File"> 
  <popup> 
    <item value="New" onclick="CreateDocument()" /> 
    <item value="Open" onclick="OpenDocument()" /> 
    <item value="Close" onclick="CloseDocument()" /> 
  </popup> 
</menu> 

JSON, on the contrary, uses a more economic syntax resembling that of C and Java programming languages. The same menu in JSON format will be as follows:

{"menu": { 
  "id": "m_file", 
  "value": "File", 
  "popup": { 
    "item": [ 
      {"value": "New", "onclick": "NewDocument()"}, 
      {"value": "Open", "onclick": "OpenDocument()"}, 
      {"value": "Close", "onclick": "CloseDocument()"} 
    ] 
  } 
}} 
主站蜘蛛池模板: 万州区| 潼关县| 长乐市| 温泉县| 龙川县| 西和县| 平昌县| 会昌县| 乃东县| 永登县| 霍山县| 泗洪县| 乌拉特后旗| 全椒县| 商都县| 商水县| 分宜县| 屏东市| 通榆县| 田东县| 乡宁县| 杂多县| 合水县| 含山县| 宜州市| 什邡市| 博湖县| 张家川| 博湖县| 图木舒克市| 枣阳市| 蒙自县| 伽师县| 柳河县| 肃北| 巴彦淖尔市| 东丰县| 靖西县| 客服| 宝应县| 贞丰县|