title: Pyspark JSON object or file to RDD
body: <p>I am new to PySpark and I have an AskReddit json file which I got from <a href="https://www.reddit.com/r/AskReddit.json" rel="nofollow noreferrer">this link</a>. I am trying to create an RDD which I then hope to perform operation such as map and flatmap. I was advised to get the json in a jsonlines format but despite using pip to install jsonlines, I am unable to import the package in the PySpark notebook. Below is what I have tried for reading in the json. </p>
  
  <pre><code>In [10]: import json
  
           data = json.load(open("AskReddit.json", "r"))
           jsonrdd = sc.parallelize(data)
           jsonrdd.take(5) 
  
  Out[11]: [u'kind', u'data']
  </code></pre>
  
  <p>I also tried to do the following which gives me the whole contents of the json file after doing jsonrdd.take(1).</p>
  
  <pre><code>In [6]: jsonrdd = sc.wholeTextFiles("*.json")
          jsonrdd.take(1)
  </code></pre>
  
  <p>However, I would like to get each json object as one line in the rdd. How would I go about this?</p>