Source JSON
- Input
- {"nome":"Ana","idade":30,"cidades":["SP","RJ"]}
- Expected output
- nome: Ana idade: 30 cidades: - SP - RJ
Converted to YAML, the cities list becomes two dashed lines, keeping a real list structure, unlike what happens with CSV.
JSON, YAML, CSV and XML conversion
JSON, YAML, CSV and XML are not four syntaxes for the same thing: each one can represent a different set of data shapes, and a conversion between them is only lossless when the source structure fits the target mold.
Converted to YAML, the cities list becomes two dashed lines, keeping a real list structure, unlike what happens with CSV.
The cities list becomes a single cell holding escaped JSON text (doubled quotes inside quotes), because CSV has no column type for a list field.
Detection follows a fixed order: starting with "<" is XML, starting with "{" or "[" is JSON, having "key: value" or "---" is YAML, and CSV is what is left when there is a comma and a line break.
JSON and YAML are interchangeable without loss, since they represent the same structures. CSV is ideal for flat lists of objects (it becomes a table) and loses deep nesting. XML has no universal mapping to objects, so we use a pragmatic convention: elements become keys and repeated tags become lists. For deeply nested data, prefer JSON or YAML.
Because CSV is a tabular format with no data type for a list or nested object. When a field in the source JSON is a list, the converter writes that list's entire content as an escaped JSON string inside a single cell, instead of creating one column per item.
This converter only reads child elements and the text inside them; tag attributes like `id="42"` are not part of the mapping and are discarded when converting XML to JSON, YAML or CSV. To preserve that data, it would need to be a child element instead of an attribute.
Detection tests for YAML before CSV: if the text has a `---` line or a "key: value" pattern, it is classified as YAML; only when neither pattern shows up and there is a comma together with a line break is the text treated as CSV.
No: the CSV parser reads every cell as text. A value like "30" or "true" arrives in the output JSON as the string "30" or "true", in quotes, not as a native number or boolean, because CSV does not store type information alongside the value.
name: jkit
tools: 150
tags:
- dev
- seo
active: true
All conversion happens in your browser. No data is sent to any server.