Skip to content

Make JsonGenerator.writeXxx() methods chainable #785

@cowtowncoder

Description

@cowtowncoder

Currently Jackson 2.x has void as return type for write methods, like:

public abstract void writeStartArray() throws IOException;

which prevents chaining of write calls. It would be nice to instead have these return JsonGenerator, but change of return type is bytecode-/binary-incompatible change and as such absolutely no-go for 2.x.
But for 3.x this would be doable. It

One possible open question here is that format-specific subtypes' overriding of write methods; should they change return type to proper "this" type? I don't want to make JsonGenerator (... misnomer at this point, but it is what it is) type-parameterized.
I guess this is not a problem for most usage but should probably decide on recommended approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xIssues to be only tackled for Jackson 3.x, not 2.x

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions