python - to read json file
<p>I'm new to JSON and Python, any help on this would be greatly appreciated. 
Below is my JSON file format:</p>

<pre><code>{
        "header": {
        "platform":"atm"
        "version":"2.0"
       }
        "details":[
       {
        "abc":"3"
        "def":"4"
       },
       {
        "abc":"5"
        "def":"6"
       },
       {
        "abc":"7"
        "def":"8"
       }    
      ]
    }
</code></pre>

<p>My requirement is to read the values of all <code>"abc"</code> <code>"def"</code> in details and add this is to a new list like this <code>[(1,2),(3,4),(5,6),(7,8)]</code>. The new list will be used to create a spark data frame.</p>

<p>Open the file, and get a filehandle:</p>

<p><a href="https://docs.python.org/2/library/functions.html#open" rel="nofollow">https://docs.python.org/2/library/functions.html#open</a></p>

<p>Then, pass the file handle into json.load():</p>

<p><a href="https://docs.python.org/2/library/json.html#json.load" rel="nofollow">https://docs.python.org/2/library/json.html#json.load</a></p>

<p>From there, you can easily deal with a python dictionary that represents your json-encoded data.</p>

python json spark-dataframe