Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉
#667 7 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
38/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
java
領域
api

研究方向

從 core/src/main/java/io/cloudevents/core/impl/BaseCloudEvent.java 第 84 行附近開始,這裡會在序列化期間讀取擴充值。使用報告中所示的自訂 Recipient 擴充功能和 withExtension 多載重現此問題,然後將序列化輸出與預期的巢狀 recipient JSON 進行比較。當自訂擴充物件能夠在沒有 JsonMappingException 的情況下完成序列化,且不會以轉義的 JSON 字串輸出時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Java
星號
447
分支
173
平均合併
16 小時 42 分鐘
30 天內合併 PR
2

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

cloudevents/sdk-java 的其他 Issue

查看 cloudevents/sdk-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。