-
Notifications
You must be signed in to change notification settings - Fork 1
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
use circe as serde lib for json: 200 #214
Open
TebaleloS
wants to merge
14
commits into
master
Choose a base branch
from
feature/#200-Use-circe-as-serde-lib-forjson
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f5e6795
Addid circe dependency and using it
TebaleloS 8e8e746
merge master
TebaleloS ac908df
modifying dependencies
TebaleloS 1dee384
merge master and use circe syntax in function classes
TebaleloS 852d4fd
using circe syntax in flow classes
TebaleloS 37b5434
using circe in api http module
TebaleloS eb77ba5
fix implicit import in ServerOptions
TebaleloS f6d2ece
merge master, fix dependencies and conclude server implicit implement…
TebaleloS 3c707e6
removing play Json dependencies, and PlayJsonImplicits class
TebaleloS 935cde0
removing play Json dependencies, and PlayJsonImplicits class
TebaleloS 3c2ca00
fixing bugs and using circe instead of Json4s dependency
TebaleloS 0f2b220
revised arrayPutUsing string implicit conversion
TebaleloS de28a5a
merge master
TebaleloS ad59999
removed json4s and replaced its usage
TebaleloS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,17 +16,19 @@ | |
|
||
package za.co.absa.atum.model.utils | ||
|
||
import org.json4s.JsonAST.JString | ||
import org.json4s.{CustomSerializer, JNull} | ||
|
||
import io.circe.{Decoder, Encoder} | ||
import java.time.ZonedDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
object ZonedDateTimeSerializer { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not used anywhere anymore and could be removed. |
||
implicit val encodeZonedDateTime: Encoder[ZonedDateTime] = Encoder.encodeString.contramap( | ||
_.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) | ||
|
||
case object ZonedDateTimeSerializer extends CustomSerializer[ZonedDateTime](_ => ( | ||
{ | ||
case JString(s) => ZonedDateTime.parse(s, SerializationUtils.timestampFormat) | ||
case JNull => null | ||
}, | ||
{ | ||
case d: ZonedDateTime => JString(SerializationUtils.timestampFormat.format(d)) | ||
implicit val decodeZonedDateTime: Decoder[ZonedDateTime] = Decoder.decodeString.emap { str => | ||
try { | ||
Right(ZonedDateTime.parse(str, DateTimeFormatter.ISO_ZONED_DATE_TIME)) | ||
} catch { | ||
case e: Throwable => Left(e.getMessage) | ||
} | ||
} | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ object Dependencies { | |
val balta = "0.1.0" | ||
|
||
val jacksonModuleScala = "2.14.2" | ||
val circeVersion = "0.14.5" | ||
|
||
val specs2 = "4.10.0" | ||
val typesafeConfig = "1.4.2" | ||
|
@@ -47,22 +46,6 @@ object Dependencies { | |
|
||
val fadb = "0.3.0" | ||
|
||
val json4s_spark2 = "3.5.3" | ||
val json4s_spark3 = "3.7.0-M11" | ||
def json4s(scalaVersion: Version): String = { | ||
// TODO done this impractical way until https://github.com/AbsaOSS/commons/issues/134 | ||
val maj2 = Component("2") | ||
val min11 = Component("11") | ||
val min12 = Component("12") | ||
val min13 = Component("13") | ||
scalaVersion.components match { | ||
case Seq(`maj2`, `min11`, _) => json4s_spark2 | ||
case Seq(`maj2`, `min12`, _) => json4s_spark3 | ||
case Seq(`maj2`, `min13`, _) => json4s_spark3 | ||
case _ => throw new IllegalArgumentException("Only Scala 2.11, 2.12, and 2.13 are currently supported.") | ||
} | ||
} | ||
|
||
val logback = "1.2.3" | ||
|
||
val zio = "2.0.19" | ||
|
@@ -74,8 +57,8 @@ object Dependencies { | |
val tapir = "1.9.6" | ||
val http4sBlazeBackend = "0.23.15" | ||
val http4sPrometheus = "0.23.6" | ||
val playJson = "3.0.1" | ||
val sttpPlayJson = "3.9.3" | ||
val circeJson = "0.14.7" | ||
val sttpCirceJson = "3.9.7" | ||
|
||
val awssdk = "2.23.15" | ||
|
||
|
@@ -107,26 +90,19 @@ object Dependencies { | |
} | ||
|
||
private def jsonSerdeDependencies(scalaVersion: Version): Seq[ModuleID] = { | ||
val json4sVersion = Versions.json4s(scalaVersion) | ||
|
||
lazy val jacksonModuleScala = "com.fasterxml.jackson.module" %% "jackson-module-scala" % Versions.jacksonModuleScala | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need this? |
||
|
||
lazy val json4sExt = "org.json4s" %% "json4s-ext" % json4sVersion | ||
lazy val json4sCore = "org.json4s" %% "json4s-core" % json4sVersion | ||
lazy val json4sJackson = "org.json4s" %% "json4s-jackson" % json4sVersion | ||
lazy val json4sNative = "org.json4s" %% "json4s-native" % json4sVersion % Provided | ||
|
||
lazy val circeCore = "io.circe" %% "circe-core" % Versions.circeVersion | ||
lazy val circeParser = "io.circe" %% "circe-parser" % Versions.circeVersion | ||
// Circe dependencies | ||
lazy val circeCore = "io.circe" %% "circe-core" % Versions.circeJson | ||
lazy val circeParser = "io.circe" %% "circe-parser" % Versions.circeJson | ||
lazy val circeGeneric = "io.circe" %% "circe-generic" % Versions.circeJson | ||
|
||
Seq( | ||
jacksonModuleScala, | ||
json4sExt, | ||
json4sCore, | ||
json4sJackson, | ||
json4sNative, | ||
circeCore, | ||
circeParser, | ||
circeGeneric, | ||
) | ||
} | ||
|
||
|
@@ -163,9 +139,17 @@ object Dependencies { | |
lazy val tapirPrometheus = tapirOrg %% "tapir-prometheus-metrics" % Versions.tapir | ||
lazy val tapirStubServer = tapirOrg %% "tapir-sttp-stub-server" % Versions.tapir % Test | ||
|
||
// json | ||
lazy val playJson = playOrg %% "play-json" % Versions.playJson | ||
lazy val sttpPlayJson = sttpClient3Org %% "play-json" % Versions.sttpPlayJson % Test | ||
lazy val tapirCirce = tapirOrg %% "tapir-json-circe" % Versions.tapir | ||
lazy val tapirOpenApiDocs = tapirOrg %% "tapir-openapi-docs" % Versions.tapir | ||
lazy val tapirOpenApiCirceYaml = tapirOrg %% "tapir-openapi-circe-yaml" % Versions.tapir | ||
lazy val tapirHttp4sServer = tapirOrg %% "tapir-http4s-server" % Versions.tapir | ||
lazy val tapirCore = tapirOrg %% "tapir-core" % Versions.tapir | ||
lazy val tapirSwaggerUi = tapirOrg %% "tapir-swagger-ui-http4s" % Versions.tapir | ||
|
||
// STTP core and Circe integration | ||
lazy val sttpCirce = sttpClient3Org %% "circe" % Versions.sttpCirceJson % Test | ||
lazy val sttpCore = sttpClient3Org %% "core" % Versions.sttpCirceJson | ||
lazy val clientBackend = sttpClient3Org %% "async-http-client-backend-zio" % Versions.sttpCirceJson | ||
|
||
// Fa-db | ||
lazy val faDbDoobie = faDbOrg %% "doobie" % Versions.fadb | ||
|
@@ -197,10 +181,11 @@ object Dependencies { | |
tapirHttp4sZio, | ||
tapirSwagger, | ||
tapirPlayJson, | ||
tapirCirce, | ||
tapirPrometheus, | ||
tapirStubServer, | ||
playJson, | ||
sttpPlayJson, | ||
sttpCirce, | ||
sttpCore, | ||
awsSecretsManagerSdk, | ||
zioTest, | ||
zioTestSbt, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole object
SerializationUtils
should be removed (or kept only for third party types serde implicits). It's customary to define serde implicits in companion objects - for default de/serialization. If needed one could then provide alternative implementation(s) either in direct scope where the de/serialization is performed or create yet another object for non-default implementations inside the companion object and in import into direct scope only the desired implementation (the preffered approach in my opinion).A simple example would be:
Usage would look like this: