blgm / jfq

JSONata on the command line
http://jsonata.org/
MIT License
49 stars 4 forks source link

jsonlines Input format #498

Open s4ke opened 3 years ago

s4ke commented 3 years ago

First of all, nice and simple tool, but tt would be great if jfq would support the jsonlines format as input just as it supports it as an output format. This would make it the perfect tool for data transformation pipelines in bash.

I will be working on a pull request.

s4ke commented 3 years ago

@blgm Something that I found out while working with the new feature a bit:

You can't use ndjson/jsonlines-output to convert an input array:

[
    {...},
    {...}
]

into a sequence of elements separated by newlines by passing it into jfq "$" --jsonlines-output/ndjson. Looking into the code I am not so sure as to how to achieve this behaviour properly though. The thing is that since we can never be sure what the jsonata would produce, we can not just check if the output is an array and then just go from there.

I don't think that this is solveable out of the box, however and we should advise all users to be aware of this edge case.