Skip to content

Commit

Permalink
0005948: KafkaDataWriter by ROW method has a trailing comma
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobvanmeter committed Aug 8, 2023
1 parent 56312b4 commit 14ae876
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -221,6 +221,9 @@ protected int execute(CsvData data, String[] values) {
}
List<ProducerRecord<String, Object>> kafkaDataList = kafkaDataMap.get(kafkaDataKey);
if (outputFormat.equals(KAFKA_FORMAT_JSON)) {
if(!kafkaDataList.isEmpty() && !messageBy.equals(KAFKA_MESSAGE_BY_ROW)) {
kafkaText.append(", ");
}
kafkaText.append("{\"").append(table.getName()).append("\": {").append("\"eventType\": \"" + data.getDataEventType() + "\",")
.append("\"data\": { ");
// Let Gson escape the json values
Expand All @@ -232,7 +235,7 @@ protected int execute(CsvData data, String[] values) {
kafkaText.append(",");
}
}
kafkaText.append(" } } }, ");
kafkaText.append(" } } }");
} else if (outputFormat.equals(KAFKA_FORMAT_CSV)) {
// Quote every non-null field, escape quote character by
// doubling the quote character
Expand Down

0 comments on commit 14ae876

Please sign in to comment.