Necesito crear la siguiente estructura como ejemplo.
Código JSON:
Ver original
[ { "servidor": "http://URL.com", "email": "[email protected], "passwd": "DELETE", "name": "pepe", "last_name": "toledo", "company": "forosdelweb", "type_server": "roundcube" }, { "servidor": "http://URL.com", "email": "[email protected], "passwd": "DELETE", "name": "pepe", "last_name": "toledo", "company": "forosdelweb", "type_server": "roundcube" } ]
Código Python:
Ver original
for person in result['results']: # print(person['name']['first']+" "+person['name']['last']+" "+person['email']) jsonOutput = {} jsonOutput['servidor'] = 'http://webmail.'+nextelem jsonOutput['email'] = clear(person['email'].replace('example.com', nextelem)) jsonOutput['passwd'] = 'P@ssw0rd' jsonOutput['name'] = clear(person['name']['first']) jsonOutput['last_name'] = clear(person['name']['last']) jsonOutput['company'] = generate_company() jsonOutput['type_server'] = 'roundcube' json_string = json.dumps(jsonOutput, indent=4) savefile = open('correos.json', 'w') savefile.write(json_string) savefile.close()