title: scala json4s handling null values
body: <p>I have a case class</p>
  
  <pre><code>case class Test(a: String, b: Option[Double])
  
  object TestSerializer extends CustomSerializer[Test] (format =&gt; ({
  case jv: JValue =&gt;
    val a = (jv \ "a").extract[String]
    val b = (jv \ "b").extractOpt
    Test(a, b)
  },{
    case tst: Test =&gt;
     tst.b match {
      case Some(x) =&gt; ("a" -&gt; "test") ~ ("b" -&gt; x)
      case None =&gt; ("a" -&gt; "test") ~ ("b" -&gt; "NA")
     }
  }))
  </code></pre>
  
  <p>When b is available, the result I get is:  <code>{a: "test", b: 1.0}</code></p>
  
  <p>When b = None, the result I get is: <code>{a: "test"}</code></p>
  
  <p>The second result throws an exception in the first partial function since it cannot find b.
  How can I ensure my code does not fail and instead treat the missing b value of json as None?</p>
  
  <p>I am using json4s 3.2.10 and not 3.2.11 so I cannot use the preserveEmpty fields option.</p>