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

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()"} 
    ] 
  } 
}} 
主站蜘蛛池模板: 大兴区| 麻城市| 长垣县| 丽江市| 含山县| 木兰县| 镇原县| 孝昌县| 肃南| 梁山县| 吴忠市| 福清市| 台南县| 安陆市| 绥德县| 舟山市| 乌兰县| 云霄县| 竹山县| 新乡市| 文山县| 合作市| 尤溪县| 莱西市| 从化市| 孝感市| 海丰县| 凌云县| 彭山县| 工布江达县| 长垣县| 南昌市| 黑水县| 高安市| 岗巴县| 三原县| 确山县| 万载县| 封丘县| 静乐县| 裕民县|