Thanks for the question! Like many things in programming, there are multiple ways to solve the same problem. The "right" way really depends on what outcomes you are looking to achieve. When you are dealing with messaging and events, I would recommend using the simplest approach possible that meets your needs. Start as simple and possible, then evolve when required to. YAGNI (
https://martinfowler.com/bliki/Yagni.html) is a good idea to live by.
Using a structured textual representation, like JSON, is a good way to convey information in a clear and concise way. However, it can be fairly verbose if you let it be. XML is another textual representation that can be used in these scenarios, but it can be even more verbose than JSON. With more verbosity comes larger payload sizes and less efficient throughput.
If you need to support a high volume of messages, then you want your events to be as small as possible. One common data format used with Kafka is Avro. It is a binary format for your data that can be mapped to the language of your choice. If you pick the Avro path, then you also need to develop schemas to help describe the data since the raw data will be in a binary format.
I would recommend the following to read more about Avro, and its benefits:
*
https://avro.apache.org/docs/current/
*
https://www.confluent.io/blog/avro-kafka-data/ (While this was published back in 2015, it does a great job of describing the benefits of using a binary data format like Avro)
*
https://docs.confluent.io/platform/current/schema-registry/serdes-develop/serdes-avro.html