Convert CSV rows to TOON without changing text values
Admin ·
Use CSV to TOON when you need a table as named records in Token-Oriented Object Notation. The first row becomes the list of field names. The data cells stay strings so a part number such as 007 retains its spelling.
Convert the two inventory rows
Paste the three lines below into CSV input. Choose Comma under TOON delimiter and select Convert to TOON. The first line supplies three column names and the other two lines supply the records.
sku,quantity,note
007,2,"Beacon, west"
010,0,RFC 4180, CSV records and quotingOfficial TOON format specification
Check the row count and the quoted cells
The TOON header begins [2]{sku,quantity,note}:. The 2 counts the data rows. The quotes around 007 and 2 preserve their string types. The first note contains a comma and the second note is an empty string.
Switch TOON delimiter to Pipe and convert the same CSV again. The header becomes [2|]{sku|quantity|note}:. The comma in Beacon, west is now ordinary text in the TOON row. The CSV source still uses commas.
[2]{sku,quantity,note}:
"007","2","Beacon, west"
"010","0",""Verify the saved records in TOON Validator
Download converted.toon and open the saved file in TOON Validator. Check that the decoded JSON has two records, with "007" for the first sku, "Beacon, west" for its note and "" for the second note.
If conversion reports unequal field counts, check that the source separates columns with commas and quotes notes containing commas. Keep the trailing comma on the second data row so the empty note remains a third cell.
RFC 4180, CSV records and quotingOfficial TOON format specification
Common questions
Can I make quantity a number instead of a string?
Prepare typed JSON first, with numbers for quantities and quoted identifiers, then use JSON to TOON.
Should I keep a CSV column name on a row by itself?
Put every column name in the same first row, separated the same way as the data rows.