how to customize the json message sent to kafka server?

the test4 send the bbox and some fake message,but how can I customize the JSON format?

In nvdsmeta_schema.h

/**
 * Payload type flags.
 */
typedef enum NvDsPayloadType {
  NVDS_PAYLOAD_DEEPSTREAM,
  NVDS_PAYLOAD_DEEPSTREAM_MINIMAL,
  /** Reserved for future use. Use value greater than this for custom payloads. */
  NVDS_PAYLOAD_RESERVED = 0x100,
  /** To support custom payload. User need to implement nvds_msg2p_* interface */
  NVDS_PAYLOAD_CUSTOM = 0x101,
  NVDS_PAYLOAD_FORCE32 = 0x7FFFFFFF
} NvDsPayloadType;

sources/gst-plugins/gst-nvmsgconv/gstnvmsgconv.c
self->msg2p_generate = (nvds_msg2p_generate_ptr) nvds_msg2p_generate;
This function will generate json payload.

How to do this in Python?