Ksqldb function puzzles to convert maps to individual messages

I have a json message
{"color":"red","quantity":"small"}",

it looks like series of map key:values,

I need to extract each pair of key:value to become a message i can sink to downstream, therefore this becomes two rows in sink:
color, red
quantity, small

I am playing with ksql functions but i don’t know how to break a single message becomes two messages that makes to possible to be sinked. . i need your brain how to play further with these functions , for example ; how can i convert the output of json_records in below that each become a message? i am thinking how to put that output back to become an array and then an explode will make it to break.

select explode(VARIANTOPTIONS) as original ,
json_keys(explode(VARIANTOPTIONS)) as json_keys ,
json_records(explode(VARIANTOPTIONS)) as json_records,
map_keys(json_records(explode(VARIANTOPTIONS))) as map_keys
from PRODUCTINSTANCE_VARIANT_OPTIONS_STREAM EMIT CHANGES;

{
“KSQL_COL_0”: “{"color":"red","quantity":"small"}”,
“JSON_KEYS”: [
“color”,
“quantity”
],
“JSON_RECORDS”: {
“color”: “red”,
“quantity”: “small”
},
“MAP_KEYS”: [
“color”,
“quantity”
]
}

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