cloudevents / sdk-java

Java SDK for CloudEvents
https://cloudevents.github.io/sdk-java/
Apache License 2.0
390 stars 159 forks source link

JsonFormat deserialization with custom extensions #668

Closed PlugaruT closed 6 days ago

PlugaruT commented 6 days ago

Hi, I'm using JsonFormat to deserialize a JSON string into a CloudEvent. Example below:

...
String dataJson = afterJsonNode.get("data").asText(); // this is how I get the json string

JsonFormat jsonFormat = new JsonFormat();
CloudEvent e = jsonFormat.deserialize(dataJson.getBytes());

Seems that if the string has a custom extension, it fails on deserialization with

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Invalid extensions name: ce_sourceid

Any idea why? Should the library pass the custom extensions further?

Thanks

PlugaruT commented 6 days ago

Seems that the extension name was not respecting the spec. It should not contain special charts. In my case it should be sourceid, without _. My bad.