In json4s, why does the extract() function always yield empty object result?

84 views Asked by At

Here is an example:


  implicit val formats: Formats = DefaultFormats

  case class StrInt(
      a: String = "A",
      b: Int = 2
  )


    val d1 = StrInt("a", 12)
    val json = decompose(d1)
    
    println(json)

The result of the above code is "JObject(Nil)", this is clearly wrong. What could be the cause and how to fix it?

BTW, this is the dependency sub-tree of my test runtime classpath:

 org.json4s:json4s-jackson_2.12:3.6.12

     org.scala-lang:scala-library:2.12.15 ➡ 2.12.16
     org.json4s:json4s-core_2.12:3.6.12
         org.scala-lang:scala-library:2.12.15 ➡ 2.12.16
         org.json4s:json4s-ast_2.12:3.6.12
             org.scala-lang:scala-library:2.12.15 ➡ 2.12.16
         org.json4s:json4s-scalap_2.12:3.6.12
             org.scala-lang:scala-library:2.12.15 ➡ 2.12.16
         com.thoughtworks.paranamer:paranamer:2.8
     com.fasterxml.jackson.core:jackson-databind:2.9.10.8
         com.fasterxml.jackson.core:jackson-annotations:2.9.10
         com.fasterxml.jackson.core:jackson-core:2.9.10

As it can be observed, every dependency is of the proper version except Scala. So this is clearly not caused by a dependency hell. What could be the case?

0

There are 0 answers