I need to create multiple JSON files from Python, for example:
[{
'commentParentId': 'abcdedf',
'parentId': '123456',
'posted': '28/02/2019',
'author': {
'id': '125379',
'name': 'david',
'email': '[email protected]
},
'content': 'i need help'
},
{
'commentParentId': 'abcdedf',
'parentId': '253654',
'posted': '28/02/2019',
'author': {
'id': '458216',
'name': 'david',
'email': '[email protected]
},
'content': 'i need help'
},
........................
}]
The example: I have 10 comments with 10 id different and I want to create 10 JSON files with each. 1 JSON file has 1 JSON object and JSON name's author id.
But in Python, to write data in JSON file I use:
with open("scrapercomment.json", "w", encoding="utf-8") as writeJSON:
json.dump(data, writeJSON, ensure_ascii=False)
I don't have an idea of how to write 10 JSON files with each name is each id. I'm a newbie Python, JSON so thanks for your help.