I have a code below
import io.circe.generic.auto._
import io.circe.Encoder
import io.circe.generic.extras._, io.circe.syntax._
implicit val config: Configuration = Configuration.default.withSnakeCaseMemberNames
case class User(firstName: String, lastName: String)
print(User("Foo", "McBar").asJson)
Its supposed to output something like
{
"first_name" : "Foo",
"last_name" : "McBar"
}
But I get
{
"firstName" : "Foo",
"lastName" : "McBar"
}
what Am I doing wrong? i thought giving implicit config will be enough !!!
import io.circe.generic.auto._
does not use Configuration
.
If you want to use configration you have to use io.circe.generic.extras.auto._
.
Generic extras (io.circe.generic.extras
) is not an extension to standard derivation (io.circe.generic
) but an alternative, and they don't mix well in the same file if you use auto
.