As the name indicates, separator is only used between values, and there is
no option to force it in the end. I don't know how easy it'd be to add an
option to also add separator before `close()`; may be worth filing an issue.

However, you should be able to write this into output stream through
Jackson API. Methods `writeRaw()` and `writeRawValue()` might both work for
this particular purpose: if using `writeRaw()`, you would write separator
String itself; if using `writeRawValue()`, I think you would try to write
empty String as it would add separator before (since call implies that you
are writing a pre-encoded JSON value and thereby a separator is needed).

-+ Tatu +-


On Wed, Jul 6, 2016 at 1:30 AM, Jakub Liska <[email protected]> wrote:

> Hey,
>
> I'm writing json objects to file as lines this way :
>
>         ObjMapper
>           .writer()
>           .withRootValueSeparator("\n")
>           .writeValues(new BufferedWriter(new OutputStreamWriter(new
> FileOutputStream(file, true), StandardCharsets.UTF_8), 524288))
>           .writeAll(recs)
>
>
> Which would be OK if I didn't write multiple times to the same file
> because the separator is not used at the end, if I write to a file 3 lines
> this way multiple times I get :
>
> {}
> {}
> {}{}
> {}
> {}{}
> {}
> {}{}
> {}
> {}{}
>
> Is there a setting for this? Or I have to do it manually by writing "\n"
> to the outputstream?
>
> --
> You received this message because you are subscribed to the Google Groups
> "jackson-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to