[Freeswitch-users] YAML support as an alternative of XML for configuration

EdPimentl edpimentl at gmail.com
Fri Jun 27 10:47:46 EDT 2008


The debate of YAML vs XML and XML vs JSON is not new...
Can YAML really replace  XML?
To be frank, whatever can  be done in XML can be done without XML.
Do you need XML for XML-RPC? Yes,
Is it necessary to use XML for RPC? No.
Is it necessary to use XML for RDF? No.
Is it necessary to use XML for, anything? No.
Is YAML a perfect replacement for XML? No
Are there  circumstances, YAML may be more suitable than XML.
http://www.ibm.com/developerworks/xml/library/x-matters23.html

YAML is designed with scripting languages (such as Python, Perl, PHP, and
Ruby, among others) in mind.
Using Python to parse YAML
PyYAML is designed to be a Python parser.

<user id="MyPBX" on="localbox">
        <firstname>John</firstname>
        <lastname>QPublic</lastname>
        <department>QA</department>
        <cell>678-255-1185</cell>
        <address password="xxxx">jqpublic at myaml.com</address>
        <address password="xxxx">jqpublic at myxml.com</address>
    </user>

Now, contrast this with what I would enter for the YAML file:

        MyPBX:
            computer : localbox
            firstname: John
            lastname: QPublic
            cell: 678-255-1185
            addresses:
                - address: jqpublic at example1.com
                  password: xxxxxxxx
                - address: jqpublic at example2.com
                  password: xxxxxxxx


Assuming we created a yaml document, and read the above  YAML structure into
Python,  the resulting structure may look like:

{mypbx: {computer: localbox, firstname: John, lastname: QPublic, cell: 678,
255,1212, addresses: [{address: jqpublic at myaml.com, password:
xxxxxxxx},{address: jqpublic at myxml.com, password: xxxxxxxx}]}

http://www.yaml.org/refcard.html
http://yaml4r.sourceforge.net/cookbook/
http://pyyaml.org/

So what about JSON then. is not JSON better than XML, YAML or OGDL?
http://scripting.wordpress.com/2006/12/20/scripting-news-for-12202006/
Briefly these do similar things in a different way.
JSON works well with Javascript.
YAML works without modification in Python and Ruby.
XML works with almost every language having xml libraries.
OGDL is similar to YAML and seems to now be adopted by JAVA
http://ogdl.sourceforge.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20080627/cb1b11ff/attachment.html 


More information about the Freeswitch-users mailing list