Add to stats.py a function to dump the DB to JSON format.