Skip to content

Commit 9aa33e8

Browse files
authored
Add zio-json (#464)
1 parent 8fafc5a commit 9aa33e8

File tree

30 files changed

+199
-37
lines changed

30 files changed

+199
-37
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Following target libraries are supported:
1414
- [play-json](https://github.com/playframework/play-json)
1515
- [upickle](https://github.com/lihaoyi/upickle)
1616
- [scalapb](https://github.com/scalapb/ScalaPB)
17+
- [zio-json](https://github.com/zio/zio-json)
1718

1819
Inspired by [https://github.com/hseeberger/akka-http-json](https://github.com/hseeberger/akka-http-json).
1920

@@ -26,28 +27,28 @@ Add dependencies for the selected integration:
2627
- for avro4s:
2728
``` scala
2829
libraryDependencies ++= List(
29-
"io.github.azhur" %% "kafka-serde-avro4s" % version,
30+
"io.github.azhur" %% "kafka-serde-avro4s" % version
3031
)
3132
```
3233

3334
- for circe:
3435
``` scala
3536
libraryDependencies ++= List(
36-
"io.github.azhur" %% "kafka-serde-circe" % version,
37+
"io.github.azhur" %% "kafka-serde-circe" % version
3738
)
3839
```
3940

4041
- for jackson:
4142
``` scala
4243
libraryDependencies ++= List(
43-
"io.github.azhur" %% "kafka-serde-jackson" % version,
44+
"io.github.azhur" %% "kafka-serde-jackson" % version
4445
)
4546
```
4647

4748
- for json4s:
4849
``` scala
4950
libraryDependencies ++= List(
50-
"io.github.azhur" %% "kafka-serde-json4s" % version,
51+
"io.github.azhur" %% "kafka-serde-json4s" % version
5152
)
5253
```
5354

@@ -80,6 +81,13 @@ libraryDependencies ++= List(
8081
)
8182
```
8283

84+
- for zio-json:
85+
``` scala
86+
libraryDependencies ++= List(
87+
"io.github.azhur" %% "kafka-serde-zio-json" % version
88+
)
89+
```
90+
8391
## Usage
8492

8593
Mix `xxxSupport` into your code which requires implicit Kafka
@@ -96,6 +104,7 @@ Provide your implicit type class instances and the magic will convert them to Ka
96104
- for play-json: `play.api.libs.json.Reads`, `play.api.libs.json.Writes`
97105
- for upickle: `upickle.default.Reader`, `upickle.default.Writer`
98106
- for scalapb: `scalapb.GeneratedMessageCompanion`
107+
- for zio-json: `zio.json.JsonEncoder`, `zio.json.JsonDecoder`
99108

100109
For more info, please, take a look at unit tests and at `kafka-serde-scala-example` which is a kafka-streams (2.x) application with kafka-serde-scala usage.
101110

build.sbt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ lazy val latest212 = "2.12.17"
2626

2727
lazy val latest213 = "2.13.10"
2828

29-
lazy val latest3 = "3.2.1"
29+
lazy val latest3 = "3.2.2"
3030

3131
lazy val `kafka-serde-scala` =
3232
project
@@ -41,6 +41,7 @@ lazy val `kafka-serde-scala` =
4141
`kafka-serde-play-json`,
4242
`kafka-serde-upickle`,
4343
`kafka-serde-scalapb`,
44+
`kafka-serde-zio-json`,
4445
`kafka-serde-scala-example`
4546
)
4647
.settings(commonSettings)
@@ -167,6 +168,22 @@ lazy val `kafka-serde-scalapb` = project
167168
.settings(
168169
Compile / PB.targets := Seq(
169170
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
171+
),
172+
Test / PB.targets := Seq(
173+
scalapb.gen() -> (Test / sourceManaged).value / "scalapb"
174+
)
175+
)
176+
177+
lazy val `kafka-serde-zio-json` = project
178+
.enablePlugins(AutomateHeaderPlugin)
179+
.settings(commonSettings)
180+
.settings(mimaSettings)
181+
.settings(
182+
crossScalaVersions := Seq(latest212, latest213, latest3),
183+
libraryDependencies ++= Seq(
184+
dependency.kafkaClients,
185+
dependency.zioJson,
186+
dependency.scalaTest % Test
170187
)
171188
)
172189

@@ -196,6 +213,7 @@ lazy val dependency =
196213
val play = "2.9.4"
197214
val upickle = "3.0.0"
198215
val jackson = "2.14.2"
216+
val zioJson = "0.4.2"
199217
}
200218
val kafkaClients = "org.apache.kafka" % "kafka-clients" % Version.kafka
201219
val kafkaStreamsScala = "org.apache.kafka" %% "kafka-streams-scala" % Version.kafka
@@ -214,6 +232,7 @@ lazy val dependency =
214232
val upickle = "com.lihaoyi" %% "upickle" % Version.upickle
215233
val jacksonScala = "com.fasterxml.jackson.module" %% "jackson-module-scala" % Version.jackson
216234
val jacksonCore = "com.fasterxml.jackson.core" % "jackson-core" % Version.jackson
235+
val zioJson = "dev.zio" %% "zio-json" % Version.zioJson
217236
val jacksonProtobuf = "com.fasterxml.jackson.dataformat" % "jackson-dataformat-protobuf" % Version.jackson
218237
val jacksonAvro = "com.fasterxml.jackson.dataformat" % "jackson-dataformat-avro" % Version.jackson
219238
val scalaTest = "org.scalatest" %% "scalatest" % Version.scalaTest
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.github.azhur.kafkaserdeavro4s
17+
package io.github.azhur.kafka.serde
1818

1919
import java.io.ByteArrayOutputStream
2020
import java.util
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.github.azhur.kafkaserdeavro4s
17+
package io.github.azhur.kafka.serde
1818

1919
import java.io.ByteArrayOutputStream
2020
import java.util
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.github.azhur.kafkaserdeavro4s
17+
package io.github.azhur.kafka.serde
1818

1919
import java.io.ByteArrayOutputStream
2020
import java.util
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.github.azhur.kafkaserdeavro4s
17+
package io.github.azhur.kafka.serde
1818

1919
import com.sksamuel.avro4s.{ Decoder, Encoder, SchemaFor }
2020
import org.apache.kafka.common.serialization.{ Deserializer, Serde, Serializer }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.github.azhur.kafkaserdeavro4s
17+
package io.github.azhur.kafka.serde
1818

1919
import com.sksamuel.avro4s.{ Decoder, Encoder, SchemaFor }
2020
import org.apache.kafka.common.serialization.{ Deserializer, Serde, Serializer }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.github.azhur.kafkaserdeavro4s
17+
package io.github.azhur.kafka.serde
1818

1919
import java.nio.charset.StandardCharsets.UTF_8
2020

kafka-serde-circe/src/main/scala/io/github/azhur/kafkaserdecirce/CirceSupport.scala renamed to kafka-serde-circe/src/main/scala/io/github/azhur/kafka/serde/CirceSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.github.azhur.kafkaserdecirce
17+
package io.github.azhur.kafka.serde
1818

1919
import java.nio.charset.StandardCharsets.UTF_8
2020
import java.util
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.github.azhur.kafkaserdecirce
17+
package io.github.azhur.kafka.serde
1818

1919
import java.nio.charset.StandardCharsets.UTF_8
2020

0 commit comments

Comments
 (0)