Comments (5)
Any news on this? We need the extensions as well.
from sdk-java.
We have found an easy workaround for this. So instead of doing this:
payloadAsString = io.cloudevents.json.Json.encode(cloudEvent);
we do this:
payloadAsString = io.cloudevents.json.Json.MAPPER.writerFor(CloudEvent.class).writeValueAsString(cloudEvent);
For some reason the latter results in a string which has extensions serialized in one of the resulting json fields
from sdk-java.
We have also run against the problem and worked around a solution with a custom Jackson attribute, unfortunately this is not really ideal and we are looking into a better way.
from sdk-java.
Something like that could be implemented at DefaultCloudEventImpl to support Json serialization for extension values
private Map<String, Object> extendedAttributes = new HashMap<>();
private void resolveExtensions(){
for (Extension extension : this.getExtensions().orElse(new ArrayList<>())) {
for (Field field : extension.getClass().getDeclaredFields()) {
try {
field.setAccessible(true);
Object value = field.get(extension);
extendedAttributes.put(field.getName(), value);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
}
@JsonAnyGetter
public Map<String, Object> getExtendedAttributes() {
return extendedAttributes;
}
from sdk-java.
I also waiting for this issue to be addressed.
from sdk-java.
Related Issues (20)
- BaseCloudEvent.getExtensionNames() breaks cloud event encapsulation HOT 2
- Add benchmarks to CloudEvents SQL HOT 1
- Does CloudEventDeserializer deserialize custom extensions (kafka headers)? HOT 3
- CVE-2022-42004 - Update jackson version HOT 3
- Spring Webflux: example not working HOT 2
- Custom validation for context attributes in wrapper library HOT 1
- can't setup `cloudevents.serializer.event_format` in quarkus HOT 3
- How to transport List<CloudEvent> between Springboot services by openfeign?
- Running into exception while using cloudevent values in kafka streams HOT 1
- Enhancement: generalise the validation in wrapper library HOT 4
- Change type of source attribute from URI to String HOT 2
- Add support for spring-amqp HOT 1
- Contribution question for wrapper for RabbitmQ and Redis HOT 8
- Port tck tests once the CESQL spec stabilizes more HOT 1
- Error assembling JAR: Invalid automatic module name: '' HOT 1
- Cannot invoke "java.lang.ClassLoader.getParent()" because "this.currentLoader" is null
- CloudEventHttpMessageConverter can't convert List<CloudEvent> HOT 2
- JsonFormat doesn't accept valid datacontentypes HOT 1
- v4.0.1 git tag included commit for 4.0.2-SNAPSHOT
- cloud events sdk for java 17 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk-java.