You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by dhanuka ranasinghe <dh...@gmail.com> on 2016/09/15 05:01:04 UTC

Kafka Source Connector - JSON with Escape double quotes

Hi,

I am using Kafka connect to feed data into kafka, please find sample code
snippet from Source Task. My question is , why kafka connect dematerialize
JSON message  by escaping double quotes? Is there way to get the same
without escaping?

byte[] message = null;
Charset charset = Charset.forName("UTF-8");
String strMsg = new String(message, charset);
log.info(strMsg);
SourceRecord record = new SourceRecord(partition, null, topic,
ConnectSchema.STRING_SCHEMA,strMsg);

From kafka console consumer :

{"schema":{"type":"string","optional":false},"payload":"
{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"rex\", \"_id\" : \"1\"
} }\n"}

From log.info() : What I really expect

INFO { "index" : { "_index" : "test", "_type" : "rex", "_id" : "1" } }


Cheers,
Dhanuka
-- 
Nothing Impossible,Creativity is more important than knowledge.