Skip to content
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

ByteStringArrayCodecs not working on Scala 3 #700

Open
OndrejSpanel opened this issue Apr 8, 2024 · 3 comments
Open

ByteStringArrayCodecs not working on Scala 3 #700

OndrejSpanel opened this issue Apr 8, 2024 · 3 comments

Comments

@OndrejSpanel
Copy link
Contributor

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]}

@sirthias
Copy link
Owner

sirthias commented Apr 8, 2024

I think with Scala 3 you have to import ByteStringArrayCodecs.LittleEndian.given.
The docs need to be updated in that respect.
👍

@OndrejSpanel
Copy link
Contributor Author

Confirmed as working. For cross-building one needs to use:

import ByteStringArrayCodecs.LittleEndian.{given, *}

Together with:

    scalacOptions += "-Xsource:3-cross",

@sirthias
Copy link
Owner

sirthias commented Apr 8, 2024

Thank you!
Will add that to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants