# Avro kafka to json stream

**URL:** <https://forum.confluent.io/t/avro-kafka-to-json-stream/10393>\
**Category:** ksqlDB\
**Created:** [14 March 2024 18:35 UTC](https://forum.confluent.io/t/avro-kafka-to-json-stream/10393 "2024-03-14T18:35:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shjoon](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@shjoon](https://forum.confluent.io/u/shjoon)\
**Post date:** [14 March 2024 18:35 UTC](https://forum.confluent.io/t/avro-kafka-to-json-stream/10393/1 "2024-03-14T18:35:39Z")

</div>

i have a avro kafka. can i make a json stream from it immediately or i need to create a avro stream first and then the second stream as json as SELECT \* from stream1?

I have an avro kafka, i have created a stream but the select doesn’t return anything from it.

i am wondering whether this structure is correct i put in the CREATE Stream is correct or not.

CREATE STREAM TcProductVariant\_stream\_AVRO (  
\_comment string ,  
data ARRAY\<STRUCT\<  
productInstanceUuid string ,  
productInstanceId string,  
productInstanceDescription string ,  
productInstanceRevision string ,  
productVariants ARRAY\<STRUCT\<operation string , TC\_variant\_id string , tc\_variant\_name string, variant\_options ARRAY \< MAP\< string,string \> \>\>\>

> >

)  
WITH (KAFKA\_TOPIC = ‘TcProductVariants’,  
VALUE\_FORMAT = ‘avro’,  
TIMESTAMP\_FORMAT = ‘yyyy-MM-dd HH:mm:ss’,  
PARTITIONS = 6);

below is an example of message in the topic

{  
“\_comment”: “W\u0013\T6\u0014[/5Cw”,  
“data”: {  
“productInstanceUuid”: “b3a50b58-ec9b-46f8-aee5-50d9f9e6aa2d”,  
“productInstanceId”: “P444555666”,  
“productInstanceDescription”: “BMX Freestyle Pro”,  
“productInstanceRevision”: “B”,  
“productVariants”: [  
{  
“operation”: “Add”,  
“Tc\_variant\_id”: “f8f3d986-b440-431e-9013-3bfdf6750bb2”,  
“Tc\_variant\_name”: “red AND large”,  
“VariantOptions”: [  
{  
“color”: “green”,  
“size”: “large”  
}  
]  
},  
{  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![dtroiano](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/dtroiano/32/1961_2.png) [@dtroiano](https://forum.confluent.io/u/dtroiano)\
**Post date:** [14 March 2024 18:46 UTC](https://forum.confluent.io/t/avro-kafka-to-json-stream/10393/2 "2024-03-14T18:46:48Z")

</div>

> [@shjoon](#):
>
> can i make a json stream from it immediately or i need to create a avro stream first and then the second stream as json as SELECT \* from stream1?

You’d need to do the latter with a second stream. [Here](https://developer.confluent.io/tutorials/changing-serialization-format/ksql.html)’s a tutorial converting Avro to Protobuf that you can follow, where you’d target `JSON` or `JSON_SR` rather than Protobuf.

---

<div class="post-metadata">

**Author:** ![shjoon](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@shjoon](https://forum.confluent.io/u/shjoon)\
**Post date:** [14 March 2024 19:07 UTC](https://forum.confluent.io/t/avro-kafka-to-json-stream/10393/3 "2024-03-14T19:07:22Z")

</div>

thank you for your quick reply.

that was the exact link i saw that made me to submit the question.

In there, it has a stream on the topic and then on the second stream it changes to protobuf with select \* from stream1

i did build two streams from my avro tppic: json and avro.  
what is the criteria for me to choose which format is appropriate for the stream?

also, my message is very nested. I need to flatten it to make it easier for sinking . I am planning to create other set of streams or create tables after these streams. I don’t know criteria to choose stream or table. is there anting you can suggest criteria to pick table versus stream for further processing? .

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [13 April 2024 18:36 UTC](https://forum.confluent.io/t/avro-kafka-to-json-stream/10393/4 "2024-04-13T18:36:34Z")

</div>

This topic was automatically closed after 30 days. New replies are no longer allowed.
