18 lines
461 B
Python
18 lines
461 B
Python
import json
|
|
import yaml
|
|
from pathlib import Path
|
|
|
|
input_file = Path("servo_config.yaml")
|
|
output_file = Path("servo_config.json")
|
|
|
|
with input_file.open("r", encoding="utf-8") as f:
|
|
data = yaml.safe_load(f)
|
|
|
|
# 删除只用于 YAML 复用的辅助字段
|
|
data.pop("default_driver", None)
|
|
data.pop("default_control", None)
|
|
|
|
with output_file.open("w", encoding="utf-8") as f:
|
|
json.dump(data, f, indent=2, ensure_ascii=False)
|
|
|
|
print(f"Generated {output_file}") |