Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kkonyshev/f040c32c3b149f46ad092ec2218e380d to your computer and use it in GitHub Desktop.
Save kkonyshev/f040c32c3b149f46ad092ec2218e380d to your computer and use it in GitHub Desktop.
import io.circe._
import io.circe.generic.auto._
import io.circe.parser._
import io.circe.syntax._
case class User(id: Long, name: String)
val user = User(1, "John Doe")
// {"id":1,"name":"John Doe"}
val json = user.asJson.noSpaces
// Right(User(1L, "John Doe"))
val res: Either[Error, User] = decode[User](json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment