[QUERY] Is it possible to serialize/deserialize EventGridEvent to/from json?
See original GitHub issueQuery/Question How can I serialize EventGridEvent to json, and then back? Please see the sample code that’s failing as follows - I think I’m not intended to be doing what I’m doing?
Unrecognized field "topic" (class com.microsoft.azure.eventgrid.models.EventGridEvent), not marked as ignorable (0 known properties: ])
It seems like EventGridEvent has the right annotations, though?
Setup (please complete the following information if applicable):
- OS: [e.g. iOS]
- IDE : [e.g. IntelliJ]
- Version of the Library used
I am trying to take the raw objects out of the event log, write them to an on premise kafka queue, then read them out of the on premise kafka queue with on premise workers. The reason these things are in an on premise setup is for security compliance demands.
Deserializer snippet:
private static final ObjectMapper objectMapper = new ObjectMapper();
@Override
public EventGridEvent deserialize(byte[] message) throws IOException {
return objectMapper.readValue(message, EventGridEvent.class);
}
Test snippet:
// SAMPLE EVENT: https://docs.microsoft.com/en-us/azure/event-grid/event-schema
byte[] sampleEvent = getClass().getClassLoader().getResourceAsStream("sampleEvent.json").readAllBytes();
System.out.println(new String(sampleEvent));
EventGridEvent event = deserializationSchema.deserialize(sampleEvent);
System.out.println(event.id());
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Query Added
- Setup information Added
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Cool I can verify that the JacksonAdaptor works. I’m very happy with those answers to my query! Please feel free to close the ticket.
Thanks for filing this issue @bytesandwich. @bsiegel could you please follow up on this track-1 inquiry?