Insert JSON in kafka using tKafkaOutput

Hello,
I have a csv file as follows:
id,first_name,last_name,email
1,x,x,x@x.com
2,y,y,y@y.com
I want to convert this to json object as follows
{
"id" : 1,
"first_name" : "x",
"last_name" : "x",
"email" : "x@x.com",
}
{
"id" : 2,
"first_name" : "y",
"last_name" : "y",
"email" : "y@y.com",
}
and now insert this each json object in kafka.
Thanks.
5 REPLIES
Twelve Stars

Re: Insert JSON in kafka using tKafkaOutput

Hi,
simple answer - see attachments, somewhere in a middle You can add transformation CSV to JSON
using tWriteJSONFileds + convert data to byte[] (in example it .getByte() )
    
-----------
One Star

Re: Insert JSON in kafka using tKafkaOutput

Hello ,
Can you give me example for tFileInputDelimited -> tWriteJSONField
I tried it but getting error

I think I am doing wrong here for configure JSON tree.
One Star

Re: Insert JSON in kafka using tKafkaOutput

Solved thanks.
You saved me.
I used tJavaRow instead of tFixedFlowInput.
One Star

Re: Insert JSON in kafka using tKafkaOutput

Hello,
How can a pass the entire row from the file as it is , to kafka.
I am not understanding how i will convert the entire row to Bytes , This time I dont want it as JSON.
I want to send it to kafka as it in the raw file.
Thank you
Twelve Stars

Re: Insert JSON in kafka using tKafkaOutput

Use tFileInputFullRow, with schema - single column - line
-----------