More is better | Json | XML | Yaml | INI | Tree |
---|---|---|---|---|---|
Human comprehension | 3 | one | four | five | five |
Easy editing | 3 | one | four | five | five |
Arbitrary hierarchy | 3 | 3 | 3 | one | five |
Ease of implementation | 3 | 2 | one | five | five |
Speed parsing / serialization | 3 | one | one | five | five |
Serialized Size | 3 | one | four | five | five |
Threading support | 0 | 0 | five | five | five |
Binary security | 3 | 0 | 0 | 0 | five |
Prevalence | five | five | 3 | 3 | 0 |
Editors support | five | five | 3 | five | one |
Support programming languages | five | five | 3 | five | one |
{ "users" : [ { "name" : "Alice" , age : 20 } ] }
<users><user><name>Alice</name><age>20</age></user></users>
{ "description" : "Hello, Alice!\nHow do you do?" }
<greeting>
Hello, <b>Alice</b>!<br/>
How do you do?
</greeting>
<greeting>
Hello, <a href="http://example.org/user/alice?ref=xe3o7rubvo283xb">Alice</a>!<br/>
How do you do?
</greeting>
<title>"Rock&roll" = life</title>
{ "title" : "\"Rock&roll\" = life" }
<html>
<head>
<title> & </title>
</head>
<body>
<h1>!</h1>
<p>, ?</p>
</body>
</html>
<script type="text/javascript" src="index.js" />
<link
rel="canonical"
href="/?article=rock%26roll&author=Nin+Jin"
/>
<!--<a href="/">top</a>-->
<?xml version="1.0" stanalone="yes" ololo?>
function getEl( id ){
return document.getElementById( id )
}
[
{ "function": {
"name": "getEl",
"args": [ "id" ],
"body": [
{ "return": [
{ "get": "document" },
{ "call": {
"name": "getElementById",
"args": [
{ "get": "id" }
]
}}
]}
]
}}
]
[ [ "function",
"getEl",
[ "id" ],
[ "return",
[ [ "get",
"document" ],
[ "call",
"getElementById",
[ "get", "id" ]
]
]
]
]
]
string data = cast(string) read( "path/to/file.tree" ); // read from file
Tree tree = Tree.parse( data , "http://example.org/source/uri" ); // parse to tree
Tree userNames = tree.select( "user name" ); // returns name-nodes
Tree userNamesValues = tree.select( "user name " ); // returns value-nodes
string name = userNames[0].name; // get node name
string stringValue = userNames[0].value; // get value as string with "\n" as delimiter
uint intValue = userNames[0].value!uint; // get value converted from string to another type
Tree[] childs = tree.childs; // get child nodes array
string uri = tree.uri; // get uri like "http://example.org/source/uri#3:2"
string data = tree.toString(); // returns string representation of tree
tree.pipe( stdout ); // prints tree to output buffer
! City : table
ID : field
type : int 11
null : false
unique : true
Name : field
type : char 35
null : true
unique : false
City
ID : 1
Name : \Kabul
City
ID : 4079
Name : \Rafah
City
ID : 23023
Name : \Moscow
Source: https://habr.com/ru/post/248147/
All Articles