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

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()"} 
    ] 
  } 
}} 
主站蜘蛛池模板: 项城市| 丹棱县| 凌海市| 城步| 运城市| 黑河市| 安庆市| 昆明市| 博白县| 田阳县| 仪征市| 北宁市| 当雄县| 旅游| 旬阳县| 瓮安县| 金乡县| 佛山市| 年辖:市辖区| 曲松县| 沙河市| 大关县| 钟山县| 策勒县| 从化市| 囊谦县| 盐亭县| 沙洋县| 沂源县| 双牌县| 南岸区| 牟定县| 偏关县| 呼伦贝尔市| 南江县| 斗六市| 万全县| 扎兰屯市| 江北区| 舟山市| 萝北县|