title: Read JSON inside a text file using spark and Scala
body: <p>I have a text file which has JSON data something like this:</p>
  
  <pre><code>{
    "element" : value,
    "id" : value,
    "total" : []
  }
  {
    "element" : value,
    "id" : value,
    "total: []
  }
  </code></pre>
  
  <p>All the JSON are new line separated.</p>
  
  <p>I am trying to load all the text files data into a temp view :</p>
  
  <pre><code>sqlContext.read.textFiles("/path").createOrReplaceTempView("result")
  
  val data = sqlContext.sql("select * from result").collect()
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>[{"element" : value,"id" : value,"total" : [] }]
  [{"element" : value,"id" : value, "total" : []}]
  </code></pre>
  
  <p>I need to extract the id and the total related to it.</p>
  
  <p>Is there a way in spark to handle this?</p>