public class JsonSchemaMessageReader extends SchemaMessageReader<com.fasterxml.jackson.databind.JsonNode>
1. Send JSON Schema string as value. (make sure there is no space in the schema string) bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic t1 \ --line-reader io.confluent.kafka.formatter.JsonSchemaMessageReader \ --property schema.registry.url=http://localhost:8081 \ --property value.schema='{"type":"string"}'
In the shell, type in the following. "a" "b"
2. Send JSON Schema record as value. bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic t1 \ --line-reader io.confluent.kafka.formatter.JsonSchemaMessageReader \ --property schema.registry.url=http://localhost:8081 \ --property value.schema='{"type":"object","properties":{"f1":{"type":"string"}}}'
In the shell, type in the following. {"f1": "value1"}
3. Send JSON Schema string as key and JSON Schema record as value. bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic t1 \ --line-reader io.confluent.kafka.formatter.JsonSchemaMessageReader \ --property schema.registry.url=http://localhost:8081 \ --property parse.key=true \ --property key.schema='{"type":"string"}' \ --property value.schema='{"type":"object","properties":{"f1":{"type":"string"}}}' "type":"string"}]}'
In the shell, type in the following. "key1" \t {"f1": "value1"}
KEY_SCHEMA, keySchema, VALUE_SCHEMA, valueSchema| Constructor and Description |
|---|
JsonSchemaMessageReader()
Constructor needed by kafka console producer.
|
| Modifier and Type | Method and Description |
|---|---|
protected SchemaMessageSerializer<com.fasterxml.jackson.databind.JsonNode> |
createSerializer(org.apache.kafka.common.serialization.Serializer keySerializer) |
protected SchemaProvider |
getProvider() |
protected com.fasterxml.jackson.databind.JsonNode |
readFrom(String jsonString,
ParsedSchema schema) |
close, configure, init, parseSchema, readRecordspublic JsonSchemaMessageReader()
protected SchemaMessageSerializer<com.fasterxml.jackson.databind.JsonNode> createSerializer(org.apache.kafka.common.serialization.Serializer keySerializer)
createSerializer in class SchemaMessageReader<com.fasterxml.jackson.databind.JsonNode>protected SchemaProvider getProvider()
getProvider in class SchemaMessageReader<com.fasterxml.jackson.databind.JsonNode>protected com.fasterxml.jackson.databind.JsonNode readFrom(String jsonString, ParsedSchema schema)
readFrom in class SchemaMessageReader<com.fasterxml.jackson.databind.JsonNode>Copyright © 2026 Confluent, Inc.. All rights reserved.