# Using Schema Registry for JSON Records

**URL:** <https://forum.confluent.io/t/using-schema-registry-for-json-records/2379>\
**Category:** Schema Registry\
**Created:** [29 July 2021 13:04 UTC](https://forum.confluent.io/t/using-schema-registry-for-json-records/2379 "2021-07-29T13:04:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![adsin27](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@adsin27](https://forum.confluent.io/u/adsin27)\
**Post date:** [29 July 2021 13:04 UTC](https://forum.confluent.io/t/using-schema-registry-for-json-records/2379/1 "2021-07-29T13:04:26Z")

</div>

Hi All,

I’m new to Confluent Cloud and deploying it using free trial of Confluent Kafka cluster.

I am trying to **produce/consume the JSON messages** from Kafka Topic using **authenticated Schema Registry** which can map Schema.

I am referring to the official documentation [https://docs.confluent.io/platform/current/schema-registry/serdes-develop/serdes-json.html](https://docs.confluent.io/platform/current/schema-registry/serdes-develop/serdes-json.html)  
but the JSON serializers mentioned here is not working.

I am getting below error:

> `Invalid value io.confluent.kafka.serializers.json.KafkaJsonSchemaSerializer for configuration value.serializer: Class io.confluent.kafka.serializers.json.KafkaJsonSchemaSerializer could not be found.`

Could you please let us know if this has been deprecated or not valid anymore? Can someone please advise here?  
Thanks.

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [29 July 2021 17:15 UTC](https://forum.confluent.io/t/using-schema-registry-for-json-records/2379/2 "2021-07-29T17:15:42Z")

</div>

See [Class io.confluent.kafka.serializers.json.KafkaJsonSchemaSerializer could not be found - Stack Overflow](https://stackoverflow.com/questions/68576395/confluent-kafka-json-schema-registry)

---

<div class="post-metadata">

**Author:** ![adsin27](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@adsin27](https://forum.confluent.io/u/adsin27)\
**Post date:** [30 July 2021 03:45 UTC](https://forum.confluent.io/t/using-schema-registry-for-json-records/2379/3 "2021-07-30T03:45:00Z")

</div>

@rmoff I have tried adding this dependency

**libraryDependencies += “io.confluent” % “kafka-json-schema-serializer” % “6.2.0”**

in my build.sbt file but it doesn’t get successful.

> Extracting structure failed, reason: not ok build status: Error (BuildMessages(Vector(),Vector(BuildFailure(sbt task failed, see log for details)),Vector(),Vector(),Error))  
> sbt task failed, see log for details

> scalaVersion := “2.12.5”  
> sbt.version = 1.5.2

Any suggestions please?

---

<div class="post-metadata">

**Author:** ![adsin27](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@adsin27](https://forum.confluent.io/u/adsin27)\
**Post date:** [4 August 2021 05:33 UTC](https://forum.confluent.io/t/using-schema-registry-for-json-records/2379/4 "2021-08-04T05:33:36Z")

</div>

Hi @rmoff,

This just got resolved by adding

> resolvers += “jitpack” at “[https://jitpack.io](https://jitpack.io)”  
> libraryDependencies += “org.everit.json” % “org.everit.json.schema” % “1.5.1”

But now even with _kafka-json-schema-serializer_ , the fields of the json records are not getting properly registered.

This is what I am trying to do:

> case class User(id: Int,name: String,contact: Int, dept: String)  
> val usr: User = User(1,“abc”,123,“A”)
> 
> val producer = new KafkaProducer\<String, User\>(props)  
> val record= new ProducerRecord(topicName, “key”, usr)  
> producer.send(record,callback).get()

KEY\_SERIALIZER\_CLASS\_CONFIG=\>“org.apache.kafka.common.serialization.StringSerializer”  
VALUE\_SERIALIZER\_CLASS\_CONFIG=\>“io.confluent.kafka.serializers.json.KafkaJsonSchemaSerializer”)

But the values are coming as **{}** in my kafka topic. If I try to print the record part, I see this getting sent: _key=key, value=User(1,“abc”,123,“A”)_  
Also, in the confluent schema registry the schema is coming as:

> {  
> “additionalProperties”: false,  
> “properties”: {},  
> “title”: “User”,  
> “type”: “object”  
> }

Not sure why it is not correctly sending the records. Any suggestions?  
I mainly want the schema registry to register all the fields of json records

> {  
> “additionalProperties”: false,  
> “properties”: {“id”: { “type”: “integer”},…},  
> “title”: “User”,  
> “type”: “object”  
> }

Thanks.

---

<div class="post-metadata">

**Author:** ![ryokota](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/ryokota/32/3901_2.png) [@ryokota](https://forum.confluent.io/u/ryokota)\
**Post date:** [13 August 2021 20:27 UTC](https://forum.confluent.io/t/using-schema-registry-for-json-records/2379/5 "2021-08-13T20:27:41Z")

</div>

You can try annotating the fields of the case class with @JsonProperty, like

```auto
case class User(@JsonProperty("id") id: Int, @JsonProperty("name") name: String, @JsonProperty("contact") contact: Int, @JsonProperty("dept") dept: String)

```

See [java - Using Jackson to (De)-serialize a Scala Case Class - Stack Overflow](https://stackoverflow.com/questions/28270621/using-jackson-to-de-serialize-a-scala-case-class)
