How to parse JSON in Spark with fasterxml without SparkSQL?
<p>I got this far:</p>

<pre><code>import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.DeserializationFeature

case class Person(name: String, lovesPandas: Boolean)

val mapper = new ObjectMapper()

val input = sc.textFile("files/pandainfo.json")
val result = input.flatMap(record =&gt; {
    try{
        Some(mapper.readValue(record, classOf[Person]))
    } catch {
        case e: Exception =&gt; None
    }
})
result.collect
</code></pre>

<p>but get <code>Array()</code> as a result (with no error). The file is <a href="https://github.com/databricks/learning-spark/blob/master/files/pandainfo.json" rel="nofollow noreferrer">https://github.com/databricks/learning-spark/blob/master/files/pandainfo.json</a> How do I go on from here?</p>

<hr>

<p>After consulting <a href="https://stackoverflow.com/questions/32495891/spark-broadcasting-jackson-objectmapper">Spark: broadcasting jackson ObjectMapper</a> I tried</p>

<pre><code>import org.apache.spark._
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.DeserializationFeature

case class Person(name: String, lovesPandas: Boolean)

val input = """{"name":"Sparky The Bear", "lovesPandas":true}"""
val result = input.flatMap(record =&gt; {
    try{
        val mapper = new ObjectMapper()
        mapper.registerModule(DefaultScalaModule)
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
        Some(mapper.readValue(record, classOf[Person]))
    } catch {
        case e: Exception =&gt; None
    }
})
result.collect
</code></pre>

<p>and got</p>

<pre><code>Name: Compile Error
Message: &lt;console&gt;:34: error: overloaded method value readValue with alternatives:
  [T](x$1: Array[Byte], x$2: com.fasterxml.jackson.databind.JavaType)T &lt;and&gt;
  [T](x$1: Array[Byte], x$2: com.fasterxml.jackson.core.type.TypeReference[_])T &lt;and&gt;
  [T](x$1: Array[Byte], x$2: Class[T])T &lt;and&gt;
</code></pre>