Sunday 30 March 2014

json_xml_yaml_data_format

Data formats: JSON, XML, YAML:
------------------------------

Text expressed as JSON:

{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}


The same text expressed as XML:

<menu id="file" value="File">
  <popup>
    <menuitem value="New" onclick="CreateNewDoc()" />
    <menuitem value="Open" onclick="OpenDoc()" />
    <menuitem value="Close" onclick="CloseDoc()" />
  </popup>
</menu>


YAML: Examples:

menu:
  id: file
  value: File
  popup:
    menuitem:
    - value: New
      onclick: CreateNewDoc()
    - value: Open
      onclick: OpenDoc()
    - value: Close
      onclick: CloseDoc()
...


http://docs.ansible.com/YAMLSyntax.html
http://demono.ru/Utilities/onlineSDConverter.aspx [ converter: JSON, XML, YAML ]





External Links:
--------------

    YAML is better for make configurations

    JSON is better for transfer data between applictions

    XML is better for make structured data in popular format, that should be not simple readable

    Google Protocol Buffers is alternative of XML, but more compact and not readable
   
   

No comments:

Post a Comment