Accepted answer
import spray.json._

case class Person(name: String)
object PersonFormat extends DefaultJsonProtocol {
  implicit val personFormat = jsonFormat1(Person)
import PersonFormat._

val source = """{ "name":"jack", "email":"" }"""

You need to define the JsonProtocol with a implicit val.


    import play.api.libs.json.Json 

    case class Sample(name:String)

    implicit val SampleJosn = Json.reads[Sample]

    val result = Json.parse("""{"name":"jack","email":""}""").as[Sample]

    val result2 = Json.parse("""{"name":"jack"}""").as[Sample] 

Your name will be mapped ignoring email.

See here the Fiddle:

Related Query

More Query from same tag