Click to copy

• Reviewed for ksqlDB 0.29

How to Read a JSON topic in ksqlDB

Use a PRINT statement to read a topic containing JSON records:

PRINT scores_topic FROM BEGINNING;

that returns :

Key format: ¯\_(Ä)_/¯ - no data processed
Value format: JSON or KAFKA_STRING
rowtime: 2022/07/19 10:18:13.763 Z, key: <null>, value: {"SCORE":4.9,"USER":{"NAME":"Charlie","AGE":54}}, partition: 4
rowtime: 2022/07/19 10:17:57.290 Z, key: <null>, value: {"SCORE":4.5,"USER":{"NAME":"Bob","AGE":25}}, partition: 0
rowtime: 2022/07/19 10:08:01.864 Z, key: <null>, value: {"SCORE":3.8,"USER":{"NAME":"Alice","AGE":30}}, partition: 3

Queries

If you need to run queries on the JSON topic, first you need to load the topic as a stream. Once you have the stream, you can query the JSON data in it.

Discover what readers are saying
topictale
Get easy to digest how-tos on ksqlDB
Sign up
Please read our Privacy Policy to understand how we protect and manage your data.
You may also like