import xmind
from xmind.core.markerref import MarkerId
def json_to_xmind(json_data, output_file):
"""将JSON数据转换为XMind文件
Args:
json_data (dict): 包含思维导图结构的JSON数据
output_file (str): 输出的XMind文件路径
"""
workbook = xmind.load(output_file)
sheet = workbook.getPrimarySheet()
sheet.setTitle("思维导图")
root_topic = sheet.getRootTopic()
root_topic.setTitle(json_data["root"])
def add_children(parent_topic, children):
for child in children:
if isinstance(child, str):
subtopic = workbook.createTopic()
subtopic.setTitle(child)
parent_topic.addSubTopic(subtopic)
elif isinstance(child, dict):
topic = workbook.createTopic()
t
09-12
6771

09-28
2864
