Mongoexport output formats

Hello, is it possible to output data to jsonlines format using mongoexport?

I do not know if you could do it directly but once you have valid json you probably can achieve your goal with jq.

Thanks Steve, I can use Python for the transform but was hoping I could do it directly. Anyway I’ll look at jq to see if this is quicker than Python. Thanks again

Hi @Andrew_Priest welcome to the community

In addition to @steevej 's suggestion: if by jsonlines you mean one valid json per line (I found the definition here) then by default mongoexport does this already (see the doc page here). In fact, you have to use the --jsonArray option for mongoexport to not do this. Is this what you’re looking for?

Best regards
Kevin

2 Likes

The following link might be useful, see Newline Delimited JSON. The interesting fact is that is used by mongosh.

1 Like