I have this list of json objects, and I'd like to create a method that returns all commit (or project) entries where project_id : 1, for example. Is this possible?
I currently have all_commits = all_data[0]['commits'] , which represents all of the commit objects, and a method def findAll(self):return all_commits which returns all of them, but I cant figure out how to return some of the records. I can return the value of a record via:
def findOne(self, index, key):
return all_commits[index][key]
But how can I return the whole object?
[
{
"commits": [
{
"project_id": "1",
"commit_title": "commit 1",
"date": "date 1",
"markdown": "markdown 1"
},
{
"project_id": "1",
"commit_title": "commit 2",
"date": "date 2",
"markdown": "markdown 2"
},
{
"project_id": "1",
"commit_title": "commit 3",
"date": "date 3",
"markdown": "markdown 3"
},
{
"project_id": "1",
"commit_title": "commit 4",
"date": "date 4",
"markdown": "markdown 4"
},
{
"project_id": "2",
"commit_title": "commit 5",
"date": "date 5",
"markdown": "markdown 5"
},
{
"project_id": "2",
"commit_title": "commit 6",
"date": "date 6",
"markdown": "markdown 6"
}
]
},
{
"projects": [
{
"id": 1,
"project_name": "GreenGlass for Groups",
"description": "Support group projects for retention agreements"
},
{
"id": 2,
"project_name": "Zumo Redesign",
"description": "New eda theme-based design"
}
]
}
]