Skip to content

Commit f17a877

Browse files
authored
Revert to json4s (#450)
* chore: revert to using json4s for internal serialization
1 parent 5760a22 commit f17a877

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

build.sbt

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,22 @@ lazy val runtime = (project in file("runtime")).settings(
5050
"com.twitter" %% "finagle-http" % "24.2.0" cross CrossVersion.for3Use2_13,
5151
"com.thesamet.scalapb" %% "scalapb-runtime" % "0.11.17",
5252
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1",
53+
"org.json4s" %% "json4s-native" % "4.0.7",
5354
"org.specs2" %% "specs2-core" % "4.20.8" % Test cross CrossVersion.for3Use2_13
5455
)
5556
},
5657
libraryDependencies ++= {
5758
CrossVersion.partialVersion(scalaVersion.value) match {
5859
case Some((2, 13)) | Some((2, 12)) =>
5960
Seq(
60-
"org.json4s" %% "json4s-native" % "4.0.7",
61-
"org.specs2" %% "specs2-mock" % "4.20.8" % Test
61+
"org.specs2" %% "specs2-mock" % "4.20.8" % Test
6262
)
6363
case Some((3, 3)) =>
6464
Seq(
65-
"org.playframework" %% "play-json" % "3.0.4",
6665
"org.scalamock" %% "scalamock" % "6.1.1" % Test
6766
)
6867
case Some((3, _)) =>
6968
Seq(
70-
"org.playframework" %% "play-json" % "3.0.4",
7169
"org.scalamock" %% "scalamock" % "7.1.0" % Test
7270
)
7371
case _ => Seq.empty
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.soundcloud.twinagle
22

3-
import play.api.libs.json.{Json, OFormat}
4-
53
/** JsonError is the JSON representation of `TwinagleException`s.
64
*
75
* If only there were some Language we could use to Define these kind of Interfaces
@@ -14,13 +12,21 @@ private[twinagle] case class JsonError(
1412
)
1513

1614
private[twinagle] object JsonError {
17-
import scala.util.control.Exception.*
15+
import org.json4s.*
16+
import org.json4s.native.Serialization
17+
import org.json4s.native.Serialization.{read, write}
1818

19-
implicit val _format: OFormat[JsonError] = Json.format[JsonError]
19+
import scala.annotation.nowarn
20+
import scala.util.control.Exception.*
21+
implicit val formats: AnyRef & Formats = Serialization.formats(NoTypeHints)
2022

23+
// known issue in json4s wrt Manifest usage that has been deprecated in scala3
24+
// will suppress this deprecation warning until this is fixed
25+
// https://github.com/json4s/json4s/issues/982
26+
@nowarn("cat=deprecation")
2127
def fromString(str: String): Option[JsonError] = allCatch opt {
22-
Json.parse(str).as[JsonError]
28+
read[JsonError](str)
2329
}
2430

25-
def toString(err: JsonError): String = Json.stringify(Json.toJson(err))
31+
def toString(err: JsonError): String = write(err)
2632
}

0 commit comments

Comments
 (0)