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

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()"} 
    ] 
  } 
}} 
主站蜘蛛池模板: 安吉县| 克山县| 那坡县| 平江县| 商都县| 柘城县| 天峨县| 忻城县| 麻江县| 荃湾区| 清涧县| 兴安县| 独山县| 天峻县| 通海县| 资源县| 大理市| 高要市| 濮阳市| 林甸县| 阿合奇县| 容城县| 恭城| 石阡县| 邹城市| 虞城县| 宁安市| 自贡市| 长兴县| 西和县| 疏勒县| 开平市| 阿巴嘎旗| 锦屏县| 翼城县| 蓬溪县| 泗阳县| 威信县| 太仆寺旗| 辰溪县| 汉沽区|