CBORGen

18 views
Skip to first unread message

TheCrisbros15

unread,
Jan 2, 2020, 4:40:04 PM1/2/20
to jackson-user
I’m using CBOR generator, and was wondering if nesting arrays is possible using it? Would I make use of the write raw value function?

Tatu Saloranta

unread,
Jan 2, 2020, 7:39:52 PM1/2/20
to jackson-user
On Thu, Jan 2, 2020 at 1:40 PM TheCrisbros15 <crisb...@gmail.com> wrote:
I’m using CBOR generator, and was wondering if nesting arrays is possible using it? Would I make use of the write raw value function?


You can write nested arrays by calling matching `writeStartArray()` and `writeEndArray()` appropriately. Need to use raw value writes is not common with CBOR generator.

-+ Tatu +-

 

TheCrisbros15 .

unread,
Jan 2, 2020, 8:36:24 PM1/2/20
to jackso...@googlegroups.com
Thanks man, I asked because I was having problems with CBORGen but when I didn’t call start object they went away. Not sure why, but you’re right I found it is possible. 

Thanks for the prompt response!

Ccd
--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/CAGrxA26_B4JVHSWRwe12F9g7rLg3qOvRf4gwehiWEUttqCUq0g%40mail.gmail.com.

TheCrisbros15

unread,
Jan 3, 2020, 12:09:26 PM1/3/20
to jackson-user
Thanks, and I wanted to know how one would specify using the cbor generator a map with a specific size? Or does the generator handle it in the background?

Tatu Saloranta

unread,
Jan 3, 2020, 2:16:00 PM1/3/20
to jackson-user
On Fri, Jan 3, 2020 at 9:09 AM TheCrisbros15 <crisb...@gmail.com> wrote:
Thanks, and I wanted to know how one would specify using the cbor generator a map with a specific size? Or does the generator handle it in the background?

CBOR has both fixed-set and indefinite variants of Object; Jackson by default uses indefinite length (indicates end by marker byte). So you do not have to do anything.

As to length-prefixed encoding: this is not yet supported, although there is an issue:


requesting it to be supported. If anyone has the itch, contributions are welcome: streaming level API exists for passing this information but generator needs to add verification that size will be obeyed, to avoid encoding invalid content. Such checking is implemented for Array output already, fwtw, so that could serve as inspiration.

-+ Tatu +-





 

TheCrisbros15 .

unread,
Jan 3, 2020, 2:28:01 PM1/3/20
to jackso...@googlegroups.com
Thanks, for letting me know. Good to know it wasn’t just me. 
--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/CAGrxA26-G4Qx7LHGdt0J6fzmqPSpYUnn4S3dywUHqv_up0Kb7g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages