Extraction.decompose fails on case class with secondary implicit arguments list : org.json4s.package$MappingException: Can't find constructor
Open
Nobody has claimed this yet.
improvement
- Dominant language
- Scala
- Stars
- 1.5k
- Forks
- 324
- Avg merge
- 4h 35m
- Merged PRs (30d)
- 30
Description
json4s version
3.6.9
scala version
2.13.3
jdk version
11.0.7
Extraction.decompose successes with :
case class CheckedValue[NUM](
value: NUM,
isPrime: Boolean,
digitCount: Long,
nth: NUM)
Extraction.decompose fails with :
case class CheckedValue[NUM](
value: NUM,
isPrime: Boolean,
digitCount: Long,
nth: NUM)(implicit numops: Integral[NUM])
Raised exception :
- should be possible to serialize / deserialize complex types with implicits *** FAILED ***
org.json4s.package$MappingException: Can't find constructor for CheckedValue
at org.json4s.reflect.package$.fail(package.scala:95)
at org.json4s.reflect.ScalaSigReader$.$anonfun$readConstructor$3(ScalaSigReader.scala:26)
at scala.Option.getOrElse(Option.scala:201)
at org.json4s.reflect.ScalaSigReader$.readConstructor(ScalaSigReader.scala:26)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder.ctorParamType(Reflector.scala:93)
at org.json4s.reflect.Reflector$ClassDescriptorBuilder.$anonfun$createConstructorDescriptors$7(Reflector.scala:182)
at scala.collection.immutable.ArraySeq.$anonfun$map$1(ArraySeq.scala:71)
at scala.collection.immutable.ArraySeq.$anonfun$map$1$adapted(ArraySeq.scala:71)
at scala.collection.immutable.ArraySeq$.tabulate(ArraySeq.scala:192)
at scala.collection.immutable.ArraySeq$.tabulate(ArraySeq.scala:171)
test snippet :
import org.json4s.native.Serialization.write
import org.json4s.DefaultFormats
import org.json4s.Extraction, Extraction.decompose
implicit val formats = DefaultFormats
val something1 = CheckedValue(value=7L, isPrime=true, digitCount=1, nth=4)
val jvalue = decompose(something1)
write(jvalue) shouldBe """{"value":7,"isPrime":true,"digitCount":1,"nth":4}"""
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the CheckedValue case class and test snippet in the issue, then read ScalaSigReader.scala around line 26 and Reflector.scala around lines 93 and 182. Done means Extraction.decompose handles the secondary implicit argument list and the shown write assertion produces the expected JSON without a MappingException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100