Closed phochste closed 9 years ago
+1,
multiline in the importer corresponds to pretty in the exporter. Basically, it's not about arrays but nice line breaks and indentation.
This could alsr be solved by distinguish "real" JSON and jsonlines (JSONL): http://jsonlines.org
Catmandu::Exporter::JSONL : current default Catmandu::Exporter:JSON : pretty Catmandu::Importer::JSONL : current default Catmandu::Importer::JSON : multiline
This would may some backwards compatibility but its a cleaner solution
What about @nichtich's idea? Should we implement this? Any votes?
Backwards compatibility is important for me. I've zillions of scripts around that expect JSON to be able to support both options
I added some simple aliases to make the options more consistent in dcaa312cac3b98aa59987f9502cf8cb0247fa237.
importing and exporting without options defaults to jsonlines. i added multiline as an alias to pretty in the exporter. i added an array option to the importer.
this enables roundtripping from the exporter to the importer with the same options: exporter JSON | importer JSON exporter JSON --array 1 | importer JSON --array 1 exporter JSON --array 1 --multiline 1 | importer JSON --array 1--multiline 1
(array and multiline switch the importer to an incremental parser that reads all these forms: [{}, {}] [{} {}] {}, {} {} {} and their pretty printed variants)
For the importer we have an option:
multiline => 0|1
to export into JSON arrays or JSON-per-line.
For the exporter we have the option:
array => 0|1
to export into JSON-per-line or JSON arrays.
Can these options get the same name (choose a pereference) and use the other as deprecated?