<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Working with JSON documents
JSON documents are very popular, especially when it comes to API responces and/or financial data. They provide nice, dictionary-like interface to data with the opportunity of working with keys rather than indecies only. Thus, Python has a built-in support for JSON documents with necessary ready-made functions. To access those functions, one needs to import the JSON library, which comes directly installed with Python.
Step1:  Let's create a sample JSON fie and save it to some variable called input.
Step2:  As you can see here, our JSON documents is nothing else than a list of two dictionaires with 3 keys each (and a value for each key). To parse it as a usual Python object (list in this case), the loads() function from the json package is used.
Step3:  Reading JSON from a file
using Pandas
Step4:  using with open()
Step5:  Writing JSON files
Step6:  Yet, as you may have already noticed, the saved JSON files not human-readible. To make them more user friendly, we may sort the Keys and provide 4-tab indentation.
Step7:  Converting JSON to CSV
<ASSISTANT_TASK:>
Python Code:
import json
Explanation: Working with JSON documents
JSON documents are very popular, especially when it comes to API responces and/or financial data. They provide nice, dictionary-like interface to data with the opportunity of working with keys rather than indecies only. Thus, Python has a built-in support for JSON documents with necessary ready-made functions. To access those functions, one needs to import the JSON library, which comes directly installed with Python.
End of explanation
input = '''[
  { "id" : "01",
    "status" : "Instructor",
    "name" : "Hrant"
  } ,
  { "id" : "02",
    "status" : "Student",
    "name" : "Jimmy"
  }
]'''
Explanation: Let's create a sample JSON fie and save it to some variable called input.
End of explanation
# parse/load string
data = json.loads(input)
# data is a usual list
type(data)
print(data)
from pprint import pprint
pprint(data)
print 'User count:', len(data), "\n"
data[0]['name']
for element in data:
    print 'Name: ', element['name']
    print 'Id: ', element['id']
    print 'Status: ', element['status'], "\n"
Explanation: As you can see here, our JSON documents is nothing else than a list of two dictionaires with 3 keys each (and a value for each key). To parse it as a usual Python object (list in this case), the loads() function from the json package is used.
End of explanation
import pandas as pd
address = "C:\Data_scraping\JSON\sample_data.json"
my_json_data = pd.read_json(address)
my_json_data.head()
Explanation: Reading JSON from a file
using Pandas
End of explanation
import json
with open(address,"r") as file:
    local_json = json.load(file)
print(local_json)
type(local_json)
pprint(local_json)
Explanation: using with open()
End of explanation
with open('our_json_w.json', 'w') as output:
    json.dump(local_json, output)
Explanation: Writing JSON files
End of explanation
with open('our_json_w.json', 'w') as output:
    json.dump(local_json, output, sort_keys = True, indent = 4)
Explanation: Yet, as you may have already noticed, the saved JSON files not human-readible. To make them more user friendly, we may sort the Keys and provide 4-tab indentation.
End of explanation
import csv, json
address = "C:\Data_scraping\JSON\sample_data.json"
with open(address,"r") as file:
    local_json = json.load(file)
with open("from_json.csv", "w") as f:
    writer = csv.writer(f)
    writer.writerow(["ID","Name","Status"])
    for item in local_json:
        writer.writerow([item['id'],item['name'],item['status']])
Explanation: Converting JSON to CSV
End of explanation
<END_TASK>