Json VS XML syntax


/ Published in: XML
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Both XML and JSON use structured approaches to mark up data. For example, an address book application might provide a Web service that yields address cards in this XML format:
  2.  
  3. <?xml version='1.0' encoding='UTF-8'?>
  4. <card>
  5. <fullname>Sean Kelly</fullname>
  6. <org>SK Consulting</org>
  7. <emailaddrs>
  8. <address type='work'>[email protected]</address>
  9. <address type='home' pref='1'>[email protected]</address>
  10. </emailaddrs>
  11. <telephones>
  12. <tel type='work' pref='1'>+1 214 555 1212</tel>
  13. <tel type='fax'>+1 214 555 1213</tel>
  14. <tel type='mobile'>+1 214 555 1214</tel>
  15. </telephones>
  16. <addresses>
  17. <address type='work' format='us'>1234 Main St
  18. Springfield, TX 78080-1216</address>
  19. <address type='home' format='us'>5678 Main St
  20. Springfield, TX 78080-1316</address>
  21. </addresses>
  22. <urls>
  23. <address type='work'>http://seankelly.biz/</address>
  24. <address type='home'>http://seankelly.tv/</address>
  25. </urls>
  26. </card>
  27.  
  28. ////////////////////////JSON /////////////////////////////////////////////
  29.  
  30. {
  31. "fullname": "Sean Kelly",
  32. "org": "SK Consulting",
  33. "emailaddrs": [
  34. {"type": "work", "value": "[email protected]"},
  35. {"type": "home", "pref": 1, "value": "[email protected]"}
  36. ],
  37. "telephones": [
  38. {"type": "work", "pref": 1, "value": "+1 214 555 1212"},
  39. {"type": "fax", "value": "+1 214 555 1213"},
  40. {"type": "mobile", "value": "+1 214 555 1214"}
  41. ],
  42. "addresses": [
  43. {"type": "work", "format": "us",
  44. "value": "1234 Main StnSpringfield, TX 78080-1216"},
  45. {"type": "home", "format": "us",
  46. "value": "5678 Main StnSpringfield, TX 78080-1316"}
  47. ],
  48. "urls": [
  49. {"type": "work", "value": "http://seankelly.biz/"},
  50. {"type": "home", "value": "http://seankelly.tv/"}
  51. ]
  52. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.