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). Instead off a JObject with 2 fields.
It was discovered when migrating my tests from maven to gradle, of which classloader loads test dependency before main jars. Thus producing the above result. Otherwise the problem won't manifest
(Original post:)
https://stackoverflow.com/questions/72587978/in-json4s-why-does-the-extract-function-always-yield-empty-object-result
Here is a simple example:
The result of the above code is
JObject(Nil)
. Instead off a JObject with 2 fields.It was discovered when migrating my tests from maven to gradle, of which classloader loads test dependency before main jars. Thus producing the above result. Otherwise the problem won't manifest
json4s version
3.5.5
scala version
2.12.16
jdk version
OpenJDK 1.8