Kafka-connector: Some fields in the JSON are being stringified in the topic

Hey all,
I connected a mongo collection with a kafka topic using MongoDB Atlas Source in confluent cloud.
I’m using JSON as the output format, however, when fetching messages from the topic, some fields in the JSON are being stringified and not being passed as an object. See attached screenshot:

The message from the topic (see the _id and engagement.history fields) :

Would love some help with understanding how to fix it.
Thanks!

Regarding the above issue this is the doc in the collection:
image

We’re experiencing the same issue and are working around it with custom serializers. I found another post on the same issue, but it looks like the referenced Jira item was resolved as “Works as Designed”, so it looks we’re going to have to continue working around it.

Hello @Jonathan_Alumot, were you able to find a workaround for your issue?

@Robert_Blackwood, while the ticket you mention explains the issue with arrays, it does not for ObjectIds class. I’m still trying to figure out why it is being serialized as string.

Hi @Henrique_Tensfeld, it looks like this is the Simplified Json formatter’s expected behavior if you are using that formatter.

True, the simplified json formatter would transform the ObjectId object into a string containing the ID itself as string. In my case, I wasn’t using it though I was getting a “stringuified” JSON object.