I have been trying to create a function to use as an importable tool for parsing json. here is my code I have so far
#json parser
def jsonimporter(file_path , env_to_return):
import json
a = open(file_path,"r") #opens and sets the file to read
data = a.read() #sets variable to read function
print(data)
json_data = json.loads(data) #loads the json data and stores it in json_data variable
print(json_data)
json_data.get(env_to_return)
return json_data
What my issue is, is that when I call the function in another file it does not display the parsed json it just displays the json as a a dict in this form;
{u'Environments': [{u'Dev': [u'111', u'222']}, {u'Qa': [u'333', u'444']}, {u'prod': [u'555', u'666']}]}
The print statements you see are just me trying to double check my answers. Also I have passed the call the correct parameters as it prints out the parameters if I ask it too. Thank you for your help!
dev = jsonimporter("test2.json","dev")
# dosomething with value
print(value)
This is how I called the function