Skip to content

Instantly share code, notes, and snippets.

@kevinmeredith
Created April 2, 2017 16:32
Show Gist options
  • Save kevinmeredith/0ff1b8ea6493311b81ad7723faeaa725 to your computer and use it in GitHub Desktop.
Save kevinmeredith/0ff1b8ea6493311b81ad7723faeaa725 to your computer and use it in GitHub Desktop.
Calling io.circe.Decoder#decodeList
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()))
@kevinmeredith
Copy link
Author

What's the right way to call this function?

@PaulAtBanno
Copy link

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