Nested JSON transformation
🔄 Source data and conversion settings
identified as - | Number of lines 0 | Number of columns 0 | The number of columns is the same -
💡 Instructions for use
- After pasting, check the recognition results first: if the separator is correct, the number of columns will be stable, but if the delimiter is incorrect, the first row will look obviously wrong.
- When the field contains commas, use tab delimiters instead, or wrap the entire field in quotation marks, both of which can prevent the structure from being cut incorrectly.
- After checking the header, the number of records should be one less than the total number of rows; if they are equal, it means that the header is regarded as data and needs to be reset.
- Numbers starting with zero will be inferred as numbers and the leading zeros will be discarded. You can preserve them by adding a prefix before transferring; rows with inconsistent column numbers need to be returned to the source for correction.
The table is only two-dimensional, and nested data must first be decided how to flatten it.
Structural differences
Tables are two-dimensional structures with only one value per cell.
Structured data can be nested arbitrarily, and fields can also contain objects and arrays.
Serialization method
Write the entire nested part as text and put it into the cell without losing the information.
The readability is poor, and the content cannot be directly filtered or counted.
Table disassembly method
Split the nested part into independent tables and use the identity column to associate it with the main table.
It is convenient for filtering and summarizing, but it is necessary to maintain multiple tables at the same time and ensure consistent identification.
Expand into columns
Nested fields are promoted to flat columns and prefixed, making them intuitive to read.
When the structure of each record is very different, the number of columns will expand, making it less clear.
Selection basis
If you want to show it to others and then transfer it back, choose serialization.
The optional table for statistical summary can be expanded into columns if the structure is unified.
Determine the purpose first and then decide the method: use serialization to show others, and split the table or expand it if you want statistics and summary.
📖 Glossary
- CSV
- Plain text table format with comma separated fields, one record per line. Its advantages are that it is versatile, small in size, and can be opened by any spreadsheet software; its disadvantage is that it lacks type information, all content is text, and you need to rely on convention to determine which column is a number or date.
- TSV
- Table format with tab-delimited fields, differing from the comma version only in the delimiter. When the field content itself contains commas (such as address, description text), using tab characters can save a lot of escaping, so data copied from spreadsheet software is often in this form.
- delimiter
- Character used to distinguish fields. It must not appear in the field content, otherwise the parsing result will be over-cut. A common practice is to choose based on the data content: use tabs if the content contains commas, replace with semicolons if the content contains tabs, and rely on quotation marks when it is unavoidable.
- Quotation mark escaping
- When delimiters or line breaks appear in the field content, use quotation marks to wrap the entire field, and the quotation marks themselves are repeated again. This is the key mechanism for text tables to express complex content, and must be observed on both sides of parsing and generation, otherwise explanatory text containing commas will definitely cut the table incorrectly.
- Header
- The first row is a header row that explains the meaning of each column. When converting to a structured format, the header is usually used as the field name; if the header is not checked, the program can only generate fields named by serial numbers, which is much less readable. The basis for judgment is whether the first line is text rather than data.
- Field type
- Whether the data in a column is numeric, Boolean, or text. The plain text format does not save type information, and inference is required when converting to a structured format: what looks like numbers is converted into numbers, and the rest remains text. Inference errors can cause subsequent calculations to treat numbers as text.
- Arrays and Objects
- There are two basic structures in structured formats: arrays represent a sequence of ordered values or records, and objects represent a set of key values with field names. A row of a table usually corresponds to an object, and the entire table corresponds to an object array. This is also the most natural correspondence between tables and structured formats.
- Nested structure
- The object contains objects or arrays. The table is two-dimensional and cannot directly express any depth of nesting. Therefore, during conversion, the nested part must be serialized into a piece of text or split into multiple tables. It is easier to figure out how to deal with this part before converting than to fix it after converting.
- encoding
- How characters are stored in the file. The same Chinese character is represented by different bytes in different encodings, and it will become garbled when opened with the wrong encoding. Text tables are especially prone to encounter this problem, because the default encoding exported by different software is not consistent, and the source should be confirmed before conversion.
- column alignment
- The number of fields in each row should be consistent. Inconsistent numbers usually mean that the delimiters in a field were not escaped correctly, causing that row to be over- or under-cut. Alignment check is the most effective format verification method and can detect problems before the data enters the subsequent process.
- null value
- There is no content in the field. It is represented differently in different formats: it is two consecutive delimiters in the table, and it may be an empty string in the structured format. When converting, you need to make it clear whether the null value should remain empty or be converted to a specific tag, otherwise the meaning will be changed.
- Conversion check
- After the conversion is completed, check whether the result is correct, including whether the number of rows is consistent, whether the columns are aligned, and whether special characters are destroyed. The easiest way is to convert the conversion result back to the original format and compare it with the original data; the two conversions can be restored, indicating that no information was lost in the process.
🔗 All keywords and tutorials
❓ FAQ
- Will the data be uploaded??
- No. All parsing and generation are completed locally in the browser, and no upload request is initiated.
- What formats are supported?
- Supports comma- and tab-delimited tabular text, as well as structured format conversion.
- Will Chinese characters be garbled??
- The page is uniformly processed in UTF-8; if the source file encoding is different, confirm it before pasting it in.
- What to do if there are commas in the field?
- Enclose the entire field in quotation marks, or use tab characters as delimiters instead.
- Do I need to check the header??
- If the first line is a text description, check it as the field name; if it is data itself, leave it unchecked.
- Can I download the results??
- Yes. After the conversion is completed, copy or download it into a file so that it can be put into other tools for further processing.