Skip to content

Unable to serialize complex (custom) extension in the expected json format #667

Open
@abhupadh

Description

@abhupadh

creating a custom extension object implementing CloudEventExtension, when using the extension (customExt) as below, and then serializing the CloudEvent, the serialization for the CloudEvent is failing with JsonMappingException.

CloudEventBuilder.v1()
        .withSource(URI.create(source))
        .withType(event_type)
        .withTime(event_time)
        .withId(event.getEventId())
        .withDataContentType(contentType)
        .withData(eventPayaload)
        .withDataSchema(URI.create(XDM_SCHEMA_URI))
        .withExtension(DATA_SCHEMA_VERSION_KEY_EXTENSION_NAME, schemaVerExt)
        .withExtension(X_ACTION_ID_KEY_EXTENSION_NAME, requestIdExt)
        .withExtension(customExt);

here is how the extension looks like. The customExt is the Recipient object
Screenshot 2024-09-06 at 4 22 54 PM

Also, if using the other supported methods withExtension (with key, value) as below, I had to send the string version of the customExt, and then if serialized the output is not in the expected format (see below). It can break our customers event
integrations. Kindly suggest.

CloudEventExtension_Methods

expected serialized CloudEvent custom extension

"recipient":{"userid":"9CE048DB5E8F485XXXXXXXXX@AdobeOrg"}

actual serialized CloudEvent custom extension

"recipient":"{\"userid\":\"9CE048DB5E8F485XXXXXXXXX@AdobeOrg\"}"

The serialization is failing while reading extensions here, as I believe the Object type value is not supported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions