Skip to content

[cbor] Consider adding support for custom tag handling #105

Open
@sscheck

Description

@sscheck

It would be nice if there were some programming interface allowing for custom tag-to-type mapping. For instance:

CborTag customTag = CborTag.fromInt(customTagValue);
CborTagDeserializer<CustomType> customTagDeserializer = new CborTagDeserializer<>() { ... };
CBORFactory cborFactory = new CBORFactory();
cborFactory.addTagDeserializer(customTag, customTagDeserializer);
ObjectMapper mapper = new ObjectMapper(cborFactory);
SomeType object = mapper.readValue(cborData, SomeType.class);

CborTagDeserializer might be defined as such:

public interface CborTagDeserializer<T>
{
    T deserializeTaggedData(byte[] taggedData);
}

Likewise, there should be a way to handle serialization:

public interface CborTagSerializer<T>
{
    byte[] serializeTaggedType(T value);
}

CborTagSerializer<CustomType> customTagSerializer = new CborTagSerializer<>() { ... };
cborFactory.addTagSerializer(customTag, customTagSerializer);
cborFactory.addTaggedTypeMapping(SomeType.class, customTag);

Are there any plans to add support for such a feature?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions