Skip to content

Commit

Permalink
Example of deserializer for jackson JsonNode (#112)
Browse files Browse the repository at this point in the history
* Example of deserializer for jackson JsonNode

* Install sbt in CI

* Install sbt for publish workflow
  • Loading branch information
gbecan authored Jan 28, 2025
1 parent a5476d0 commit 5aba5a2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
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)
}
}

0 comments on commit 5aba5a2

Please sign in to comment.