Export data from database into JSON file