title: Parsing large JSON file with Scala and JSON4S
body: <p>I'm working with Scala in IntelliJ IDEA 15 and trying to parse a large twitter record json file and count the total number of hashtags. I am very new to Scala and the idea of functional programming. Each line in the json file is a json object (representing a tweet). Each line in the file starts like so:</p>
  
  <pre><code>{"in_reply_to_status_id":null,"text":"To my followers sorry..
  {"in_reply_to_status_id":null,"text":"#victory","in_reply_to_screen_name"..
  {"in_reply_to_status_id":null,"text":"I'm so full I can't move"..
  </code></pre>
  
  <p>I am most interested in a property called "entities" which contains a property called "hastags" with a list of hashtags. Here is an example:</p>
  
  <pre><code>"entities":{"hashtags":[{"text":"thewayiseeit","indices":[0,13]}],"user_mentions":[],"urls":[]},
  </code></pre>
  
  <p>I've browsed the various scala frameworks for parsing json and have decided to use json4s. I have the following code in my Scala script.</p>
  
  <pre><code>    import org.json4s.native.JsonMethods._
  
      var json: String = ""
      for (line &lt;- io.Source.fromFile("twitter38.json").getLines) json += line
      val data = parse(json)
  </code></pre>
  
  <p>My logic here is that I am trying to read each line from twitter38.json into a string and then parse the entire string with parse(). The parse function is throwing an error claiming: </p>
  
  <blockquote>
    <p>"Type mismatch, expected: Nothing, found:String."</p>
  </blockquote>
  
  <p>I have seen examples that use parse() on strings that hold json objects such as </p>
  
  <pre><code>val jsontest =
  """{
      |"name" : "bob",
      |"age" : "50",
      |"gender" : "male"
      |}
  """.stripMargin
  val data = parse(jsontest)
  </code></pre>
  
  <p>but I have received the same error. I am coming from an object oriented programming background, is there something fundamentally wrong with the way I am approaching this problem?</p>