Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of deserializer for jackson JsonNode #112

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
distribution: temurin
java-version: 11
check-latest: true
- uses: sbt/setup-sbt@v1
- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ jobs:
distribution: temurin
java-version: 11
check-latest: true
- uses: sbt/setup-sbt@v1
- name: Tests
run: sbt clean test
11 changes: 10 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import org.typelevel.scalacoptions.ScalacOptions
import sbtassembly.AssemblyPlugin.autoImport.*


name := "my_custom_deserializers"
version := sys.env.getOrElse("CREATED_TAG", "0.1")
Expand All @@ -7,7 +9,9 @@ libraryDependencies += "org.apache.kafka" % "kafka-clients" % "3.4.0"
libraryDependencies ++= Seq(
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf",
"com.thesamet.scalapb.common-protos" %% "proto-google-common-protos-scalapb_0.11" % "2.9.6-0" % "protobuf",
"com.thesamet.scalapb.common-protos" %% "proto-google-common-protos-scalapb_0.11" % "2.9.6-0"
"com.thesamet.scalapb.common-protos" %% "proto-google-common-protos-scalapb_0.11" % "2.9.6-0",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.14.3"

)

Compile / tpolecatExcludeOptions ++= Set(
Expand Down Expand Up @@ -35,3 +39,8 @@ ThisBuild / credentials += Credentials(
GITHUB_OWNER,
System.getenv("GITHUB_TOKEN")
)

assembly / assemblyMergeStrategy := {
case PathList("META-INF", "versions", "9", "module-info.class") => MergeStrategy.first
case x => (assembly / assemblyMergeStrategy).value(x)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.example.conduktor.custom.deserializers

import com.fasterxml.jackson.databind.{JsonNode, ObjectMapper}
import org.apache.kafka.common.serialization.Deserializer

class MyCustomJsonNodeDeserializer extends Deserializer[JsonNode] {
override def deserialize(topic: String, data: Array[Byte]): JsonNode = {
val mapper = new ObjectMapper()
mapper.readTree(data)
}
}