Created
September 16, 2015 21:47
-
-
Save maheshkelkar/8a9d2706f61ce786af60 to your computer and use it in GitHub Desktop.
circe failure to find implicit value for parameter d, with 0.2.0-SNAPSHOT
This file contains 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
CirceTest.scala | |
================= | |
package mvkpackage | |
import io.circe._ | |
import cats.data.Xor | |
import scala.io.Source | |
object Main extends App { | |
case class ServerConfig( | |
val a: String = "test", | |
val b: Int = 99 | |
) | |
object ServerConfig2 { | |
def derive[A](input: String): Xor[Error, A] = | |
jawn.decode[A](input) | |
implicit val ServerConfigDecoder: Decoder[ServerConfig] = Decoder.instance[ServerConfig]( c => { | |
for { | |
value <- (c.downField("a")).as[String] //c.as[ServerConfig] | |
} yield ServerConfig(value) | |
} | |
) | |
} | |
val whatread = Source.fromFile("config.json").mkString | |
val blah = ServerConfig2.derive[ServerConfig](whatread) | |
println(blah) | |
} | |
config.json: | |
============ | |
{"a":"dong","b":110} | |
build.sbt | |
========== | |
resolvers += "twitter-repo" at "http://maven.twttr.com" | |
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots" | |
//resolvers += Resolver.sonatypeRepo(“snapshots”) | |
scalaVersion := "2.11.6" | |
libraryDependencies ++= Seq( | |
"io.circe" %% "circe-core" % "0.2.0-SNAPSHOT", | |
"io.circe" %% "circe-generic" % "0.2.0-SNAPSHOT", | |
"io.circe" %% "circe-jawn" % "0.2.0-SNAPSHOT" | |
) | |
Error: | |
========= | |
[error] /Users/mkelkar/tools/scala-circe/CirceTest.scala:16: could not find implicit value for parameter d: io.circe.Decoder[A] | |
[error] jawn.decode[A](input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment