How to Convert Struct to JSON...

1,856 views
Skip to first unread message

Michael Burbidge

unread,
Nov 28, 2016, 7:31:22 PM11/28/16
to Confluent Platform
I'm writing a Kafka sync connector. I'm using the Avro converter. The put method on my sink task receives a collection of SinkRecords. A SinkRecord has a valueSchema and value. How do I convert the value (of type Struct) using the schema to a JSON string? I assume there's a serializer somewhere that does this.

Thanks,
Michael-

Dustin Cote

unread,
Nov 29, 2016, 2:32:03 PM11/29/16
to confluent...@googlegroups.com
Does the JsonConverter in from the Kafka project suit your needs?


--
You received this message because you are subscribed to the Google Groups "Confluent Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to confluent-platform+unsub...@googlegroups.com.
To post to this group, send email to confluent-platform@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/confluent-platform/c8df6311-cfc6-46b2-aed5-e2f5397f67ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dustin Cote
Customer Operations Engineer | Confluent
Follow us: Twitter | blog

Michael Burbidge

unread,
Nov 29, 2016, 5:24:30 PM11/29/16
to Confluent Platform
Thanks for the response. I got my answer on another thread.


On Tuesday, November 29, 2016 at 11:32:03 AM UTC-8, Dustin Cote wrote:
Does the JsonConverter in from the Kafka project suit your needs?

On Mon, Nov 28, 2016 at 7:31 PM, Michael Burbidge <mbur...@gmail.com> wrote:
I'm writing a Kafka sync connector. I'm using the Avro converter. The put method on my sink task receives a collection of SinkRecords. A SinkRecord has a valueSchema and value. How do I convert the value (of type Struct) using the schema to a JSON string? I assume there's a serializer somewhere that does this.

Thanks,
Michael-

--
You received this message because you are subscribed to the Google Groups "Confluent Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to confluent-platform+unsub...@googlegroups.com.
To post to this group, send email to confluent...@googlegroups.com.

taher khopoliwala

unread,
Jan 16, 2017, 2:14:24 AM1/16/17
to Confluent Platform
Hi Michael,

Can you please suggest the answer you found for Struct to JSON converter?

Ewen Cheslack-Postava

unread,
Jan 31, 2017, 12:49:30 AM1/31/17
to Confluent Platform
Connect Structs are structured data that should easily translate into JSON objects. But you shouldn't need to worry about this -- the provided JsonConverter should do this translation automatically. If you're writing a Task, you shouldn't worry about serialization formats -- just use the Connect Data API and return data in a reasonable format. From there, the Converters configured by the user (whether JSON, Avro, or some other format) will handle serializing the data into a format supported by downstream applications.

-Ewen

On Sun, Jan 15, 2017 at 11:14 PM, taher khopoliwala <aire...@gmail.com> wrote:
Hi Michael,

Can you please suggest the answer you found for Struct to JSON converter?


On Wednesday, 30 November 2016 03:54:30 UTC+5:30, Michael Burbidge wrote:
Thanks for the response. I got my answer on another thread.

On Tuesday, November 29, 2016 at 11:32:03 AM UTC-8, Dustin Cote wrote:
Does the JsonConverter in from the Kafka project suit your needs?

On Mon, Nov 28, 2016 at 7:31 PM, Michael Burbidge <mbur...@gmail.com> wrote:
I'm writing a Kafka sync connector. I'm using the Avro converter. The put method on my sink task receives a collection of SinkRecords. A SinkRecord has a valueSchema and value. How do I convert the value (of type Struct) using the schema to a JSON string? I assume there's a serializer somewhere that does this.

Thanks,
Michael-

--
You received this message because you are subscribed to the Google Groups "Confluent Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to confluent-platform+unsubscribe@googlegroups.com.



--
Dustin Cote
Customer Operations Engineer | Confluent
Follow us: Twitter | blog

--
You received this message because you are subscribed to the Google Groups "Confluent Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to confluent-platform+unsubscribe@googlegroups.com.
To post to this group, send email to confluent-platform@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/confluent-platform/1255843a-19db-4391-98e5-17972fcfba30%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages