Unable to set proper JSON in Kafka message with Kafka Producer Connector. I’m sending the following value in the Message Value
context([ {"key":"cloud_events_version","value":"0.1"}, {"key":"event_type_version","value":"1.0.0"}, {"key":"event_id","value":uuid}, {"key":"event_type","value":"com.test"}, {"key":"content_type","value":"application/json"}, {"key":"data","value":context([ {"key":"source_name", "value":source_name}, {"key":"type","value": if source_name = "OfflineIngestion" then "OFFLINE_SUBMISSION" else "STUDENT_SUBMISSION"}, {"key":"uuid","value":uuid}, {"key":"id","value":id}])}, {"key":"source","value":"test"}, {"key":"event_time","value": replace(string(now()),"\..*","Z")}, {"key":"extensions","value":null}])
When I use org.springframework.kafka.support.serializer.JsonSerializer
, the message in the topic is getting saved as
"{source=test, content_type=application/json, data={source_name=OfflineIngestion, type=OFFLINE_SUBMISSION, uuid=83b566c2-435c-4f77-8d0b-761960204c67, id=123456}, event_type_version=1.0.0, extensions=null, event_id=83b566c2-435c-4f77-8d0b-761960204c67, event_time=2023-03-28T18:09:45Z, event_type=test, cloud_events_version=0.1}"
When I use StringSerializer, the message is getting saved as
{source=test, content_type=application/json, data={source_name=OfflineIngestion, type=OFFLINE_SUBMISSION, uuid=83b566c2-435c-4f77-8d0b-761960204c67, id=123456}, event_type_version=1.0.0, extensions=null, event_id=83b566c2-435c-4f77-8d0b-761960204c67, event_time=2023-03-28T18:00:57Z, event_type=test, cloud_events_version=0.1}
what is the correct approach to save the message in proper JSON format, can you please share some info on it?