-
Notifications
You must be signed in to change notification settings - Fork 329
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
Extraction fails with Scala 3 ("Can't find ScalaSig") #1035
Comments
My issue is probably related. I can't serialize any case class if it contains any List, Option or anything. Also fail with same ScalaSig error So following works import org.json4s._
import org.json4s.jackson.Serialization
import org.json4s.jackson.Serialization.{read, write}
case class A(value: Int)
case class B(value: Option[Int])
case class C(value: List[Int])
implicit val formats: Formats = DefaultFormats
write(A(1)) // works
write(List(A(1), A(2))) // works
write(Option(1)) // works
write(B(Option(1))) // doesn't
write(List(1,2)) // works
write(C(List(1,2))) // doesn't From the documentation I get impression that these simple case classes should work automatically without creating custom serializers for everything that has any Option, List etc. |
I found this issue after figuring out I had a similar error: Any update on a work around or fix? |
I ended up switching my project to Jackson (https://github.com/FasterXML/jackson-module-scala). I still ran into a problem, which may be related to yours: I had to replace |
Yet another workaround is using jsoniter-scala. It is safer and much efficient in the runtime with support of Only difference that for each top-level type of message you will need to derive a codec explicitly. It can be done using |
This bug is nearly a year old and I think completely breaks json4s in scala 3 (at least it does for my use case). Are there any plans to address this? |
fwiw, it looks like the byte code representation of scala 3 removed the "ScalaSignature" annotation which is required by json4s here https://github.com/json4s/json4s/blob/master/scalap/src/main/scala/org/json4s/scalap/scalasig/ScalaSig.scala#L43 I'm not really sure what this is used for or how to acquire this info otherwise. At a glance (though I'm far from an expert) the byte code looks roughly the same otherwise. |
This is still present in scala 3.2.2 and json4s 4.0.6 (and 4.1.0-M3). |
This is still present in json4s 4.0.6 and 4.1.0-M3 with scala 3.3.0. |
The error still occurs in versions #!/usr/bin/env -S scala-cli -q
//> using scala 3.3.1
//> using dep org.json4s::json4s-native:4.0.7
import org.json4s.{Extraction, DefaultFormats, Formats}
case class Test(value: Option[Int])
implicit val formats: Formats = DefaultFormats
Extraction.decompose(Test(Some(0))) Output: Exception in thread "main" org.json4s.MappingException: Can't find ScalaSig for class case$minusclass$minusoption$minuserror$_$Test |
This patch removes `json4s` from `common` and `network`. Json4s doesn't seem to work with scala 3. Since we're already fairly invested in circe lets remove that. See: json4s/json4s#1035
This patch removes `json4s` from `common` and `network`. Json4s doesn't seem to work with scala 3. Since we're already fairly invested in circe lets remove that. See: json4s/json4s#1035
This patch removes `json4s` from `common` and `network`. Json4s doesn't seem to work with scala 3. Since we're already fairly invested in circe lets remove that. See: json4s/json4s#1035
This patch removes `json4s` from `common` and `network`. Json4s doesn't seem to work with scala 3. Since we're already fairly invested in circe lets remove that. See: json4s/json4s#1035
This patch removes `json4s` from `common` and `network`. Json4s doesn't seem to work with scala 3. Since we're already fairly invested in circe lets remove that. See: json4s/json4s#1035
json4s version
scala version
jdk version
failure
A type is defined as a case class:
This simple test fails:
with an error:
The text was updated successfully, but these errors were encountered: