import json
def save_result_to_json(result, output_path='/root/answer.json'):
"""
Save result to JSON file with proper formatting.
Args:
result: Dictionary with earthquake result data
output_path: Path where JSON file should be written
"""
# Validate all required fields are present
required_fields = ['id', 'place', 'time', 'magnitude', 'latitude', 'longitude', 'distance_km']
for field in required_fields:
if field not in result:
raise ValueError(f"Missing required field: {field}")
with open(output_path, 'w') as f:
json.dump(result, f, indent=2)
print(f"Result saved to {output_path}")
Output Result to JSON File
Write the final result dictionary to a JSON file at `/root/answer.json` with proper formatting and field validation. Use this skill as the final step to save the analysis result.
Output Result to JSON File by cxcscmu · 8f2e3b0
npx get-skill add cxcscmu/output-result-to-json-file File contents
---name: output-result-to-json-filedescription: Write the final result dictionary to a JSON file at `/root/answer.json` with proper formatting and field validation. Use this skill as the final step to save the analysis result.metadata: source: https://skillmd.com/skills/cxcscmu/output-result-to-json-file---```pythonimport jsondef save_result_to_json(result, output_path='/root/answer.json'): """ Save result to JSON file with proper formatting. Args: result: Dictionary with earthquake result data output_path: Path where JSON file should be written """ # Validate all required fields are present required_fields = ['id', 'place', 'time', 'magnitude', 'latitude', 'longitude', 'distance_km'] for field in required_fields: if field not in result: raise ValueError(f"Missing required field: {field}") with open(output_path, 'w') as f: json.dump(result, f, indent=2) print(f"Result saved to {output_path}")```
cxcscmu/SkillLearnBench commit 8f2e3b0de2
Frequently asked questions
Run npx get-skill add cxcscmu/output-result-to-json-file in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Write the final result dictionary to a JSON file at `/root/answer.json` with proper formatting and field validation. Use this skill as the final step to save the analysis result. It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
cxcscmu (@cxcscmu) published this skill. Their other Agent Skills are listed on their SkillMD profile.