title: How to read a string as a long passed in JSON using Play framework
body: <p>I am having problems writing a Reads for JSON passed from the client to the server.  The client always sends ids as Strings when they should be Numbers.  This causes issues when I try and Read them into a Scala object.  My case class expects them to be Long to match up with the DB but I am unsure how to read the String as Long.  I tried simply using .readNullable[Long] on employer_id but then it just returns validation errors that it expected a jsnumber.  </p>
  
  <p>Play-Scala 2.4.1</p>
  
  <p>Scala 2.11.7</p>
  
  <pre><code>implicit val person_reads: Reads[Person] = (
      Reads.pure(-1L) and
      Reads.pure(None) and
      (JsPath \ "person" \ "given_name").readNullable[String](minLength[String](1)) and
      (JsPath \ "person" \ "surname").readNullable[String](minLength[String](1)) and
      (JsPath \ "person" \ "city").readNullable[String] and
      (JsPath \ "person" \ "state").readNullable[String] and
      (JsPath \ "person" \ "county").readNullable[String] and
      (JsPath \ "person" \ "zip").readNullable[String] and
      (JsPath \ "person" \ "country").readNullable[String] and
      (JsPath \ "person" \ "email").readNullable[String](email) and
      (JsPath \ "person" \ "phone").readNullable[String] and
      (JsPath \ "person" \ "employer_id").readNullable[String] and
      Reads.pure(Set[Long]()) and
      Reads.pure("") and
      Reads.pure("")
  )(Person.apply _)
  
  case class Person(
      id:Long, 
      facebook_id:Option[Long], 
      given_name:Option[String], 
      surname:Option[String], 
      city:Option[String], 
      state:Option[String], 
      county:Option[String], 
      zip:Option[String], 
      country:Option[String], 
      email:Option[String], 
      phone:Option[String], 
      employer_id:Option[Long], 
      people_connection_ids:Set[Long], 
      added:String, 
      modified:String
  )
  </code></pre>
  
  <p>Example JSON POST/PUT</p>
  
  <pre><code>{
    "person": {
      "id": 78447,
      "facebook_id": 12345678987654321,
      "given_name": "Jon",
      "surname": "Smith",
      "city": "",
      "state": "",
      "county": "",
      "zip": "",
      "country": "",
      "email": "",
      "phone": "",
      "added": "",
      "modified": "",
      "employer_id": "1289592", &lt;- This one gets passed as a string instead of number
      "people_connection_ids": [
        73
      ]
    }
  }
  </code></pre>
  
  <p>Thanks for the help</p>