The json file I'm reading from looks like this, I decided to not to post the actual file since it's for a class project and don't feel comfortable posting that(it is validated):
{ "peoples": [
{blah1 : blah, blah2: blah,blah3 : blah, blah4: blah,blah5 : blah,
blah6:blah,blah7 : blah, blah8: blah,blah9 : blah, blah10: blah,}
{blah1 : blah, blah2: blah,blah3 : blah, blah4: blah,blah5 : blah,
blah6:blah,blah7 : blah, blah8: blah,blah9 : blah, blah10: blah,}
]
}
My Code on python looks like this so far, I'm not entirely sure that this is the best way to code for this situation but it does work partially and why I'm asking for assistance:
import simplejson
class People(dict):
def __init__(self):
self.tricks = []
_keys = ['blah1', 'blah2', 'blah3','blah4', 'blah5', 'blah6','blah7',
'blah8','blah9','blah10']
def getJSONdata(self,tricks):
with open(Dfile.json, 'r') as peopleData:
dataObject = simplejson.load(peopleData)
for people in dataObject['peoples']:
return (people[tricks])
peep = People()
peep1 = People()
print(peep.getJSONdata("blah1"))
print(peep1.getJSONdata("blah2"))
I can access anything on the object using keys but can't access the second, etc... I have looked through multiple json and python sites and nothing really addresses this issue. Any help would be appreciated.
I'd like to be able to access the objects equally. so i could get blah1 from object1, object2 etc..