Created
June 26, 2020 14:50
-
-
Save kkonyshev/f040c32c3b149f46ad092ec2218e380d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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