Kafka message produced is received in the topic as an array of JSON instead of a plain JSON

asked 2019-06-16 00:44:14 -0600

Sumith Sebastian gravatar image

I have a scenario where a JSON in the following format needs to be picked from the Kafka topic, do a REST service call based on a particular field in the JSON message, populate some other fields in the message body, remove a diff tag and send it to another topic.

Sample origin message

{ "context": { "contextKey": "contextValue" }, "body": { "bodyKey": "bodyValue" }, "diff": [ { "key1": "value1" } ] }

In this scenario, the JSON produced in the destination topic is generated with a

[ { "context": { "contextKey": "contextValue" }, "body": { "bodyKey": "bodyValue" } } ]

instead of

{ "context": { "contextKey": "contextValue" }, "body": { "bodyKey": "bodyValue" } }

Please help. How do I correct this ?

edit retag flag offensive close merge delete