Atitit. Selection of manual configuration list files and data hierarchy Attilax summarize best practices --yaml
1. Yaml is a good choice : 1
2. Hierarchical structure of data-structure:hash,list, and block literal. 1
3. Yaml differs from JSON implementation 1
4. the advantages of XML and JSON issues 2
4.1. IDE- friendly 2
4.2. JSON is also suitable with any data, complex struts difficult to read 2
4.3. JSON difficult to manually maintain 3
5. YAML-based Open source project parsing YAML files The most common Java libraries are Jvyaml 3
6. YAML IDE Support 3
7. Reference 3
1. YamlIt's a good choice...
A list, using json Manual maintenance cumbersome , double quotes also Dolan .
2. Hierarchical structure of data-structure:Hash,List, andblock literal. 3. YamlwithJSONThe implementation difference
Hash(hash)
By indenting the sub-segments and using a colon (:) between the keyword and the valueto achieve the creation of the hash , using the natural carriage return long fld Segmentation
Another way is to use the JSON-compatible curly brace syntax ({}) syntax, with each pair of keywords/values separated by commas (,), such as
Author :: Old Wow's paw attilax ayron, email:[email protected]
Reprint please indicate source: Http://blog.csdn.net/attilax
List(list)
Create a listby placing a minus sign (-) in front of each list element, together with a space indent to form the YAML The cornerstone of:
Components: -JTextArea -Jbutton |
Another way to do this is to use the JSON -compatible square brackets ([]) syntax, such as:
Block literal(text block)
This is the highlight of YAML, especially compared to XML , where its CDATA is fairly rudimentary,andblock literal You can insert large chunks of text into a file carefully, and you can use a vertical bar ( | ) command to keep a new line in your text, such as:
Text: | This is a really long text |
4. xmlthe advantages andJSONthe problem4.1. IDEFriendly
YAML does not provide a schema or DTD concept, so it is not possible to verify that the file format matches your expectations,and the verboseXML has its value, but in general it is because the XML Maturity makes it a lot of extra tools to verify its format, and YAML hasn't .
4.2. JSONalso fit with any data, complexStrutsdifficult to read
It is primarily geared towards improving the size of performance and file size, because it hardly uses spaces and closing tags, however, the contents of theJSON file add complexity, and its close identity is like hell, which is JavaFx the most painful thing to see in the code, which is based on JSON, is that in a data file, using the UI structure makes the result more complex, and its complexity almost makes the file unintelligible.
4.3. JSONdifficult to maintain manually
With the {} structure and [] manifest, making it difficult to manually maintain large JSON-style files, YAML uses its space-indentation method to solve this problem skillfully, when
5. YAML-based Open source project parsing YAML files The most common Java libraries are Jvyaml
Please forgive me for introducing our own open source project here, and when I really don't know other Yaml-based open source projects other than JRuby, JRuby's Ruby on Rails framework implementation relies heavily on YAML, not XML or JSON, to see my Java Builder Library (http://www.javabuilders.org/), which leverages YAML files to provide a way to define screen controls, layouts, event lines, and data bindings to implement a description UI into Java.
6. Yaml's IDE Support
For Eclipse, there is Eclipse YAML editor (http://code.google.com/p/yamleditor/), and for NetBeans you can use a package from Ruby (http ://www.netbeans.org/features/ruby/index.html) Yaml Editor, however, the Yaml editor in NetBeans 6.1 is useless, It only supports a small subset of YAML (for example: it does not support block literal)
7. Reference
Beyond XML and JSON:YAML- on the water side - Blog channel -CSDN. Net.htm
Atitit. Manual configuration list file selection and hierarchy of data Attilax summarize best practices--yaml