Data format (CSV, XML, JSON, YAML)

(1) The text

defines a fixed format, and the length of each data is mostly fixed (a certain byte to a certain byte represents a data), such as a Log file. for example:
quote
101rensanning36male 
102tom       30male 
103ruby      25female


When serialized mostly as data, such data also does not need to wrap:
quote
101rensanning36male  102tom       30male  103ruby      25female


(2) CSV: Comma-Separated Values ​​Comma-

separated data, Excel is opened by default. Generally, the first line is the title, and the second line and later is the data. Generally, the new line represents the end of the data. If there are special characters such as spaces or line changes in the data, it needs to be enclosed in double quotation marks. Mostly used for data import and export. There are also variant definitions such as TSV, which are based on the Tab-delimited data format. Common file: data.csv

no,name,age,gender
101, rensanning, 36, bad
102,tom,30,male
103,ruby,25,female


(3) XML: Extensible Markup Language

Nested tags represent data hierarchy and are mostly used to provide API (Web Service), Java configuration files, Office files (DOCX), etc. If there are special characters in the data such as [&][<][>], etc., they need to be converted into corresponding reference entities. Common file: pom.xml
<?xml version=”1.0″encoding=”utf-8″?>
<list>
  <customer>
    <no>101</no>
    <name>rensanning</name>
    <age>36</age>
    <gender>male</gender>
  </customer>

  <customer>
    <no>102</no>
    <name>tom</name>
    <age>30</age>
    <gender>male</gender>
  </customer>

  <customer>
    <no>103</no>
    <name>ruby</name>
    <age>25</age>
    <gender>female</gender>
  </customer>
</list>


(4) JSON: JavaScript Object Notation

Braces (square brackets) represent data hierarchy, an alternative to XML, and are mostly used to provide API (REST), configuration files, NoSQL databases, etc. If there are special characters in the data such as ["][\][/], etc., they need to be escaped by escape characters. Support string/number/true/false/null/array/object, common file: package.json

[
  {"no": 101, "name": "ruby", "age": 25, "gender": "female"},
  {"no": 102, "name": "tom", "age": 30, "gender": "male"},
  {"no": 103, "name": "rensanning", "age": 36, "gender": "male"}
]


(5) YAML: YAML Ain't Markup Language

uses space indentation to represent the hierarchical structure of data, which is mostly used in configuration files. Common files: application.yml

list:
  -  no: 101
     name: ruby
     age: 25
     gender: female
  -  no: 102
     name: tom
     age: 30
     gender: male
  -  no: 103
     name: rensanning
     age: 36
     gender: male


(6) Other

.properties
Java programs are used to configure program parameters, and are also used to store localized text in multiple languages, such as log4j.properties, messages.properties.ini

Windows
platform configuration files, such as php.ini,

mysql.ini.conf
Most of the configuration files of the Linux platform have their own special syntax, such as httpd.conf, nginx.conf

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326397310&siteId=291194637