FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
316 stars 136 forks source link

Jackson Ion Nested ArrayBuffer? #206

Open jfuehner opened 4 years ago

jfuehner commented 4 years ago

Hi! Was curious if it is possible to nest a Java ByteBuffer within an Ion object? When de/serialized would it maintain that type?

For example say I have a class such as:

class Sample {
     String getId(){}
     ByteBuffer getChildren(){}
}

As an example with standard Jackson de/serializing to JSON the ByteBuffer loses its type as it is turned into a standard array... Was curious if de/serializing to/from an Ion object would allow it to maintain the ByteBuffer type...

cowtowncoder commented 4 years ago

No, Jackson simply binds ByteBuffers to/from binary data. In theory polymorphic type handling could help, but I suspect that if this is something you really need to retain, custom (de)serializers might be the way to go. I don't think Ion as format matters a lot since while it has type ids (and ability to define multiple unlike other supported formats), mapping of that is handled by jackson-databind.