Created
April 2, 2017 16:32
-
-
Save kevinmeredith/0ff1b8ea6493311b81ad7723faeaa725 to your computer and use it in GitHub Desktop.
Calling io.circe.Decoder#decodeList
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.parser._ | |
import io.circe.syntax._ | |
scala> val ints = "[1,2,3]".asJson | |
ints: io.circe.Json = "[1,2,3]" | |
scala> Decoder.decodeList[Int].decodeJson(ints) | |
res1: io.circe.Decoder.Result[List[Int]] = Left(DecodingFailure([A]List[A], List())) |
I presume you mean:
@ val ints = parse("[1,2,3]").right.get
ints: Json = [
1,
2,
3
]
@ ints.as[List[Int]].right.get
res13: List[Int] = List(1, 2, 3)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What's the right way to call this function?