YAML ↔ JSON コンバーター
YAMLとJSON形式を即座に相互変換。
よくある質問
コード実装
import yaml
import json
# YAML to JSON
yaml_text = """
name: Alice
age: 30
hobbies:
- reading
- coding
active: true
"""
data = yaml.safe_load(yaml_text)
json_output = json.dumps(data, indent=2)
print(json_output)
# JSON to YAML
json_text = '{"name": "Bob", "scores": [95, 87, 92]}'
data2 = json.loads(json_text)
yaml_output = yaml.dump(data2, default_flow_style=False, allow_unicode=True)
print(yaml_output)Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.