title: Update case class from incomplete JSON with Argonaut or Circe
body: <p>I need to create an updated instance from a case class instance (with any needed <code>DecodeJson</code>s implicitly derived), given an incomplete json (some fields missing). How can this be accomplished with Argonaut (preferably) or Circe (if I have to)?</p>
  
  <p>Example:</p>
  
  <pre><code>case class Person(name:String, age:Int)
  val person = Person("mr complete", 42)
  val incompletePersonJson = """{"name":"mr updated"}"""
  val updatedPerson = updateCaseClassFromIncompleteJson(person, incompletePersonJson)
  
  println(updatedPerson)
  //yields Person(mr updated, 42) 
  </code></pre>
  
  <p>I'm pretty sure I have to parse the json to json AST, then convert it to Shapeless <code>LabelledGeneric</code>, then use Shapeless update somehow to update the case class instance.</p>
  
  <hr>
  
  <p><strong>Edit 2</strong></p>
  
  <p>After reading the Shapeless source I found that I can generate my own "Default"-object. I managed to create a solution which requires the instance of the case class to be present while parsing the json. I was hoping to avoid this and instead provide the instance later. Anyway here it is:</p>
  
  <pre><code>import shapeless._
  import argonaut._
  import ArgonautShapeless._
  import shapeless.ops.hlist.Mapper
  
  case class Person(name: String, age: Int)
  
  object MkDefault {
  
    object toSome extends Poly1 {
      implicit def default[P] = at[P](Some(_))
    }
  
    def apply[P, L &lt;: HList, D &lt;: HList]
    (p: P)
    (implicit
     g: Generic.Aux[P, L],
     mpr: Mapper.Aux[toSome.type, L, D]
    ): Default.Aux[P, mpr.Out] =
      Default.mkDefault[P, D](mpr(g.to(p)))
  }
  
  
  object Testy extends App {
      implicit val defs0 = MkDefault(Person("new name? NO", 42))
      implicit def pd = DecodeJson.of[Person]
      val i = """{"name":"Old Name Kept"}"""
      val pp = Parse.decodeOption[Person](i).get
      println(pp)
  }
  </code></pre>
  
  <p>This yields <code>Person(Old Name Kept,42)</code>.</p>