question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

could not find Lazy implicit value of type io.circe.generic.decoding.DerivedDecoder[A] implicit val comDecoder: Decoder[SolrDoc] = deriveDecoder

See original GitHub issue

Here’s my case I have some json from finagle http get client :

package com.hendisantika.circe

import cats.syntax.either._
import io.circe.{Decoder, Json}
import io.circe.optics.JsonPath._
import io.circe.parser._
import io.circe.generic.semiauto._

object TryCirce extends App {


  val json: String = """
    {
      "responseHeader":{
        "status":0,
        "QTime":1,
        "params":{
        "indent":"true",
        "q":"content_t:circe &&\narticle_id_l:6729941",
        "wt":"json"}},
      "response":{"numFound":1,"start":0,"docs":[
      {
        "id":"comment:9404033",
        "comment_id_l":9404033,
        "article_id_l":6729941,
        "reply_to_id_l":0,
        "user_id_l":1686628,
        "username_s":"uzumaki_naruto",
        "email_s":"uzumaki_naruto@konohagakure.co.jp",
        "content_t":"Hello circe! I am learning about you now ",
        "report_i":0,
        "type_s":"comment",
        "category_is":[71],
        "category_ss":["JSON"],
        "created_dt":"2016-05-19T02:12:01Z",
        "created_ts_l":1463623921,
        "is_deleted_i":0,
        "country_code_s":"id",
        "_version_":1534721405555310592},
        {
        "id":"comment:14995036",
        "comment_id_l":14995036,
        "article_id_l":10169921,
        "reply_to_id_l":0,
        "user_id_l":1148579,
        "username_s":"uchiha_madara",
        "email_s":"uchiha_madara@akatsuki.co.jp",
        "content_t":"Hai circe, You are very handsome.",
        "report_i":0,
        "type_s":"comment",
        "category_is":[71],
        "category_ss":["LIB"],
        "created_dt":"2017-01-10T01:28:51Z",
        "created_ts_l":1484011731,
        "is_deleted_i":0,
        "country_code_s":"id",
        "_version_":1556099467469389824}]
      }}"""


  implicit val comDecoder: Decoder[SolrDoc] = deriveDecoder[SolrDoc]


  val obj = decode[SolrDoc](json2) match {
    case Left(failure) => println("Oh no --> " + failure)
    case Right(com) => println("OK Success")
      println(com)
  }

}

case class SolrDoc(response: Option[SolrResponse])

case class SolrResponse(
                       numFound:Int,
                       start : Int,
                       docs : List[Article]
                       )

case class Article(
                        id: String,
                        comment_id_l: Option[Long],
                        article_id_l: Option[Long],
                        reply_to_id_l: Option[Long],
                        user_id_l: Option[Long],
                        username_s: Option[String],
                        email_s: Option[String],
                        content_t: String,
                        report_i: Option[Int],
                        type_s: Option[String],
                        category_is: List[Int],
                        category_ss: List[String],
                        created_dt: Option[String],
                        created_ts_l: Option[Long],
                        is_deleted_i: Option[Int],
                        country_code_s: Option[String],
                        version: Option[Long]
                      )

//Error:(43, 47) could not find Lazy implicit value of type io.circe.generic.decoding.DerivedDecoder[A]
  implicit val comDecoder: Decoder[SolrDoc] = deriveDecoder

// Error:(43, 47) not enough arguments for method deriveDecoder: (implicit decode: shapeless.Lazy[io.circe.generic.decoding.DerivedDecoder[A]])io.circe.Decoder[A].
Unspecified value parameter decode.
  implicit val comDecoder: Decoder[SolrDoc] = deriveDecoder

could not find Lazy implicit value of type io.circe.generic.decoding.DerivedDecoder[A] implicit val comDecoder: Decoder[SolrDoc] = deriveDecoder

I want to decode the JSON Object to scala case class object
Do you have any solution?
I read the issue about circe from google too.
How I solve the issue. Thanks



Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

66reactions
travisbrowncommented, Jun 26, 2017

Semi-automatic derivation won’t automatically derive decoders for nested case classes. The following should work just fine:

case class SolrDoc(response: SolrResponse)
case class SolrResponse(docs: Seq[Article])
case class Article()

object TryCirce extends App {
  import io.circe.Decoder
  import io.circe.generic.semiauto.deriveDecoder

  implicit val decodeArticle: Decoder[Article] = deriveDecoder[Article]
  implicit val decodeSolrResponse: Decoder[SolrResponse] = deriveDecoder[SolrResponse]
  implicit val decodeSolrDoc: Decoder[SolrDoc] = deriveDecoder[SolrDoc]
}

It also works with the real Article. Please reopen if this doesn’t fix your issue.

10reactions
punkratz312commented, Jun 12, 2017
case class SolrDoc(response: SolrResponse)

case class SolrResponse(docs: Seq[Article])

case class Article()

object TryCirce extends App {


  import io.circe.generic.semiauto.deriveDecoder

  implicit val comDecoder: Decoder[SolrDoc] = deriveDecoder[SolrDoc]


}
 could not find Lazy implicit value of type io.circe.generic.decoding.DerivedDecoder[models.foo.SolrDoc]
[error]   implicit val comDecoder: Decoder[SolrDoc] = deriveDecoder[SolrDoc]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Circe deriveDecoder/deriveEncoder could not find Lazy ...
So, the way I found to make this work was to implement Encoders and Decoders to both ValuationRequest and ValuationResponse, ...
Read more >
circe/circe - Gitter
I still get an error. Error:(32, 68) could not find Lazy implicit value of type io.circe.generic.decoding.DerivedDecoder[Operation] implicit val ...
Read more >
Circe is driving me insane : r/scala - Reddit
But this keeps giving me compilation error could not find Lazy implicit value of type io.circe.generic.extras.decoding.
Read more >
Warnings and known issues - circe
Rename your files/directories so that the files containing types that get encoded/decoded come alphabetically before the files that import io.circe.generic.auto ...
Read more >
Circe | Encoding And Decoding - Scala Exercises
Circe uses Encoder and Decoder type classes for encoding and decoding. ... function that will convert any A to a Json and a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found