`ByteStringArrayCodecs` not working on Scala 3
OndrejSpanel opened this issue · comments
Ondřej Španěl commented
Following code works differently on Scala 2 / Scala 3. In Scala 3 the ByteStringArrayCodecs
import does nothing. The issue is present both in Cbor and Json, I show here Json version because of easier output comparison.
package com.github.ondrejspanel.borer
import io.bullet.borer._
import io.bullet.borer.derivation.MapBasedCodecs._
import ByteStringArrayCodecs.LittleEndian._
case class Data(
d: Array[Double]
)
object Data {
implicit val encoder: Encoder[Data] = deriveEncoder
}
object Main {
def main(args: Array[String]): Unit = {
val data = Data(Array(1.0, 2.0))
val binary = Json.encode(data).toUtf8String
println(binary)
}
}
Scala 2 output:
{"d":"AAAAAAAA8D8AAAAAAAAAQA=="}
Scala 3 output:
{"d":[1.0,2.0]}
Mathias commented
I think with Scala 3 you have to import ByteStringArrayCodecs.LittleEndian.given
.
The docs need to be updated in that respect.
👍
Ondřej Španěl commented
Confirmed as working. For cross-building one needs to use:
import ByteStringArrayCodecs.LittleEndian.{given, *}
Together with:
scalacOptions += "-Xsource:3-cross",
Mathias commented
Thank you!
Will add that to the docs.