Closed marycourtland closed 4 years ago
We'd have to have a jsonl
option for writeFile
for writing out an array in jsonl
format for creating new jsonl files.
@jprichardson what are your thoughts here? Is this out of scope?
what are your thoughts here? Is this out of scope?
yes
Since the append option (i.e.
flag: "a"
) injsonfile.writeFile
simply appends the new JSON object to the end of the file, it produces a file which is compatible with the JSONL format. It would be convenient if this file was readable withjsonfile.readFile
, which would return an array of the objects in the file.The only catch is that JSONL requires each line to be valid JSON. This means that it's incompatible with the
spaces
formatting option.I think it would be best to require an explicit option to be passed to
readFile
, rather than implicitly detecting the format. (E.g.format: "jsonl"
)Related issue: https://github.com/jprichardson/node-jsonfile/issues/52 (and many other closed issues). This is not suggesting the same functionality, but it solves the same problem.