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

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()"} 
    ] 
  } 
}} 
主站蜘蛛池模板: 盐源县| 孟州市| 四平市| 临沧市| 和田市| 张掖市| 腾冲县| 象州县| 于都县| 台前县| 临汾市| 秦皇岛市| 大埔区| 万宁市| 习水县| 乐陵市| 尚义县| 八宿县| 二连浩特市| 栾川县| 菏泽市| 秦安县| 九龙城区| 铜陵市| 始兴县| 和硕县| 金华市| 台北县| 双城市| 宁都县| 宁海县| 孝感市| 巴南区| 高密市| 株洲市| 东兰县| 卢氏县| 阿拉善右旗| 龙南县| 泽州县| 密山市|