Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(cbor) Introduce the writePOJO (or writeObject) with the element size #329

Open
Kieun opened this issue Jul 14, 2022 · 2 comments
Open

(cbor) Introduce the writePOJO (or writeObject) with the element size #329

Kieun opened this issue Jul 14, 2022 · 2 comments
Labels

Comments

@Kieun
Copy link

Kieun commented Jul 14, 2022

CBOR has some variants to optimize the encoded output size to indicate the length of the elements.
Jackson CBOR generator has been supporting such feature by introducing some public methods.
But, there is no such variant method for writeObject or writePOJO.
In order to properly generate the optimized output (some implementation forces to optimize the output due to interoperability), it would be better to have such features in the CBOR generator.

So, new API signature seems to be

public void writePOJO(Object pojo, int elementsToWrite) throws IOException
or
public void writePOJO(Object pojo, boolean makeDefiniteLength) throws IOException

@cowtowncoder
Copy link
Member

cowtowncoder commented Jul 14, 2022

I don't think this is possible to implement at that level, unfortunately; CBORGenerator will essentially delegate back to ObjectMapper which does serialization. But this is not to say that it might not be possible to implement support at databind level. It would require significant changes to BeanSerializer, to determine if the number of properties is easy enough to reliably detect (may not be when filtering with @JsonView or alternatives is used, f.ex). But might be doable.

But who knows. I'll leave this open: I agree that it'd be nice to be able to have this work for POJOs too.

@cowtowncoder
Copy link
Member

Overlapping with #3, fwtw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants