Page MenuHomePhabricator

Add type decoding support to tsv2json
Closed, ResolvedPublic

Description

This is necessary for converting old TSV files to new JSON files.

The utility currently expects that all values are strings.

$ echo -e "rev_id\tdamaging\n1\ttrue\n2\tfalse\n3\tfalse" | tsv2json 
{"damaging": "true", "rev_id": "1"}
{"damaging": "false", "rev_id": "2"}
{"damaging": "false", "rev_id": "3"}

This is less useful and requires lots of work in sed to clean things up. Adding type decoding will allow the following code to work.

$ echo -e "rev_id\tdamaging\n1\ttrue\n2\tfalse\n3\tfalse" | tsv2json int bool 
{"damaging": true, "rev_id": 1}
{"damaging": false, "rev_id": 2}
{"damaging": false, "rev_id": 3}