import json
import sys
def export_sandbox_results(results, output_file="sandbox_results.json"):
"""
Exports sandbox results to a JSON file with minimal memory usage.
Args:
results (list): A list of sandbox entry results (dictionaries).
output_file (str): The name of the output JSON file.
"""
try:
with open(output_file, 'w') as f:
json.dump(results, f, indent=4) # Serialize to JSON with indentation
print(f"Sandbox results exported to {output_file}")
except Exception as e:
print(f"Error exporting results: {e}")
if __name__ == '__main__':
# Example Usage (replace with your actual results)
sample_results = [
{"entry_id": 1, "status": "success", "output": "Result 1"},
{"entry_id": 2, "status": "failure", "output": "Error message"},
{"entry_id": 3, "status": "success", "output": "Result 3"}
]
export_sandbox_results(sample_results)
Add your comment