大数据

processOn json分析

最小可用json格式

{
  "diagram": {
    "elements": {
      "comments": [],
      "plugins": {},
      "elements": {
        "0-1": {
          "shapeStyle": { "alpha": 1 },
          "anchors": [
            { "x": "w/2", "y": "0" },
            { "x": "w/2", "y": "h" },
            { "x": "0", "y": "h/2" },
            { "x": "w", "y": "h/2" }
          ],
          "textBlock": [
            {
              "position": { "w": "w-20", "h": "h", "x": 10, "y": 0 },
              "text": "<section><span style='font-size:14px;font-family:Arial;color:#000000;'><b>项目启动</b></span></section>"
            }
          ],
          "title": "矩形",
          "fontStyle": {
            "fontFamily": "Arial",
            "size": 14,
            "color": "0,0,0",
            "textAlign": "center",
            "vAlign": "middle"
          },
          "props": { "zindex": 1, "w": 120, "x": 100, "h": 40, "y": 100, "angle": 0 },
          "path": [
            {
              "actions": [
                { "x": "0", "action": "move", "y": "0" },
                { "x": "w", "action": "line", "y": "0" },
                { "x": "w", "action": "line", "y": "h" },
                { "x": "0", "action": "line", "y": "h" },
                { "x": "0", "action": "line", "y": "0" }
              ]
            }
          ],
          "lineStyle": { "lineStyle": "solid", "lineColor": "0,0,0", "lineWidth": 1 },
          "children": [],
          "resizeDir": ["tl", "tr", "br", "bl"],
          "name": "Shape.1",
          "fillStyle": { "color": "255,255,255", "type": "solid" },
          "id": "0-1",
          "attribute": {
            "container": false,
            "rotatable": true,
            "visible": true,
            "collapsable": false,
            "collapsed": false,
            "linkable": true,
            "markerOffset": 5
          },
          "category": "basic",
          "locked": false
        },
        "0-2": {
          "shapeStyle": { "alpha": 1 },
          "anchors": [
            { "x": "w/2", "y": "0" },
            { "x": "w/2", "y": "h" },
            { "x": "0", "y": "h/2" },
            { "x": "w", "y": "h/2" }
          ],
          "textBlock": [
            {
              "position": { "w": "w-20", "h": "h", "x": 10, "y": 0 },
              "text": "<section><span style='font-size:14px;font-family:Arial;color:#000000;'><b>项目立项</b></span></section>"
            }
          ],
          "title": "矩形",
          "fontStyle": {
            "fontFamily": "Arial",
            "size": 14,
            "color": "0,0,0",
            "textAlign": "center",
            "vAlign": "middle"
          },
          "props": { "zindex": 2, "w": 120, "x": 100, "h": 40, "y": 180, "angle": 0 },
          "path": [
            {
              "actions": [
                { "x": "0", "action": "move", "y": "0" },
                { "x": "w", "action": "line", "y": "0" },
                { "x": "w", "action": "line", "y": "h" },
                { "x": "0", "action": "line", "y": "h" },
                { "x": "0", "action": "line", "y": "0" }
              ]
            }
          ],
          "lineStyle": { "lineStyle": "solid", "lineColor": "0,0,0", "lineWidth": 1 },
          "children": [],
          "resizeDir": ["tl", "tr", "br", "bl"],
          "name": "Shape.2",
          "fillStyle": { "color": "255,255,255", "type": "solid" },
          "id": "0-2",
          "attribute": {
            "container": false,
            "rotatable": true,
            "visible": true,
            "collapsable": false,
            "collapsed": false,
            "linkable": true,
            "markerOffset": 5
          },
          "category": "basic",
          "locked": false
        },
        "0-3": {
          "shapeStyle": { "alpha": 1 },
          "anchors": [
            { "x": "w/2", "y": "0" },
            { "x": "w/2", "y": "h" },
            { "x": "0", "y": "h/2" },
            { "x": "w", "y": "h/2" }
          ],
          "textBlock": [
            {
              "position": { "w": "w-20", "h": "h", "x": 10, "y": 0 },
              "text": "<section><span style='font-size:14px;font-family:Arial;color:#000000;'><b>前期管理</b></span></section>"
            }
          ],
          "title": "矩形",
          "fontStyle": {
            "fontFamily": "Arial",
            "size": 14,
            "color": "0,0,0",
            "textAlign": "center",
            "vAlign": "middle"
          },
          "props": { "zindex": 3, "w": 120, "x": 100, "h": 40, "y": 260, "angle": 0 },
          "path": [
            {
              "actions": [
                { "x": "0", "action": "move", "y": "0" },
                { "x": "w", "action": "line", "y": "0" },
                { "x": "w", "action": "line", "y": "h" },
                { "x": "0", "action": "line", "y": "h" },
                { "x": "0", "action": "line", "y": "0" }
              ]
            }
          ],
          "lineStyle": { "lineStyle": "solid", "lineColor": "0,0,0", "lineWidth": 1 },
          "children": [],
          "resizeDir": ["tl", "tr", "br", "bl"],
          "name": "Shape.3",
          "fillStyle": { "color": "255,255,255", "type": "solid" },
          "id": "0-3",
          "attribute": {
            "container": false,
            "rotatable": true,
            "visible": true,
            "collapsable": false,
            "collapsed": false,
            "linkable": true,
            "markerOffset": 5
          },
          "category": "basic",
          "locked": false
        }
      },
      "page": {
        "padding": 20,
        "backgroundColor": "255,255,255",
        "gridSize": 10,
        "width": 300,
        "name": "Page-1",
        "showGrid": true,
        "lineJumps": true,
        "richText": true,
        "height": 400
      },
      "version": 1
    }
  },
  "meta": {
    "exportTime": "2026-01-14 13:45:00",
    "member": "",
    "diagramInfo": {
      "creator": "",
      "created": "2026-01-14 13:45:00",
      "modified": "2026-01-14 13:45:00",
      "title": "未命名文件",
      "category": "flow"
    },
    "id": "未命名文件_001",
    "type": "ProcessOn Schema File",
    "version": "5.0"
  }
}

使用gpt生成根据架构图反推的提示词

system_prompt

You are a senior data platform architect.

Your task is NOT to redraw the image,
but to reverse-engineer the system architecture shown in the image
into a STRICT, STRUCTURED, MACHINE-READABLE description.

Rules you MUST follow:
1. Focus on STRUCTURE, not visual style.
2. Identify logical layers, components, and data flow direction.
3. Do NOT invent components that are not clearly present.
4. Do NOT include coordinates, colors, or layout pixels.
5. Do NOT output diagrams, markdown, or natural language explanations.

Output must be a SINGLE valid JSON object.

The JSON must be deterministic, minimal, and stable.
Assume the output will be used to programmatically generate diagrams.

Think like an engineer reverse-engineering a system design document,
not like an illustrator.

If information is ambiguous, choose the most conservative interpretation.

user_prompt

To generate the required structured JSON description of the system architecture, the **system architecture image** is missing. 

Please provide the clear content of the system architecture diagram (including logical layers, components, data flow directions, and their relationships), and I will reverse-engineer it into a deterministic, minimal, and machine-readable JSON object that complies with all your requirements.

上传架构图解析出json数据,保存到本地architecture_dsl

python读取json,并组装适合.pos文件的json

import json
from datetime import datetime


# ===============================
# ProcessOn 最小稳定矩形模板
# ===============================
def rect_shape(id, name, text, x, y, z):
    return {
        "shapeStyle": {"alpha": 1},
        "anchors": [
            {"x": "w/2", "y": "0"},
            {"x": "w/2", "y": "h"},
            {"x": "0", "y": "h/2"},
            {"x": "w", "y": "h/2"}
        ],
        "textBlock": [
            {
                "position": {"x": 10, "y": 0, "w": "w-20", "h": "h"},
                "text": (
                    "<section>"
                    "<span style='font-size:14px;font-family:Arial;color:#000000;'>"
                    f"<b>{text}</b>"
                    "</span>"
                    "</section>"
                )
            }
        ],
        "title": "矩形",
        "fontStyle": {
            "fontFamily": "Arial",
            "size": 14,
            "color": "0,0,0",
            "textAlign": "center",
            "vAlign": "middle"
        },
        "props": {
            "x": x,
            "y": y,
            "w": 220,
            "h": 60,
            "zindex": z,
            "angle": 0
        },
        "path": [
            {
                "actions": [
                    {"action": "move", "x": "0", "y": "0"},
                    {"action": "line", "x": "w", "y": "0"},
                    {"action": "line", "x": "w", "y": "h"},
                    {"action": "line", "x": "0", "y": "h"},
                    {"action": "line", "x": "0", "y": "0"}
                ]
            }
        ],
        "lineStyle": {
            "lineStyle": "solid",
            "lineColor": "0,0,0",
            "lineWidth": 1
        },
        "fillStyle": {
            "color": "255,255,255",
            "type": "solid"
        },
        "children": [],
        "resizeDir": ["tl", "tr", "br", "bl"],
        "name": name,
        "category": "basic",
        "locked": False,
        "id": id,
        "attribute": {
            "container": False,
            "rotatable": True,
            "visible": True,
            "collapsable": False,
            "collapsed": False,
            "linkable": True,
            "markerOffset": 5
        }
    }


# ===============================
# DSL → ProcessOn Elements
# ===============================
def render_architecture(architecture):
    elements = {}
    shape_index = 1

    # 布局参数(你后续可以调)
    base_x = 60
    base_y = 60
    layer_gap = 120
    component_gap = 260

    for layer_idx, layer in enumerate(architecture["layers"]):
        y = base_y + layer_idx * layer_gap
        components = layer.get("components", [])

        for comp_idx, comp in enumerate(components):
            x = base_x + comp_idx * component_gap

            element_id = f"0-{shape_index}"
            elements[element_id] = rect_shape(
                id=element_id,
                name=f"Shape.{shape_index}",
                text=comp["name"],
                x=x,
                y=y,
                z=shape_index
            )
            shape_index += 1

    return elements


# ===============================
# 主入口
# ===============================
def main():
    # 1. 读取 DSL
    with open("architecture_dsl.json", "r", encoding="utf-8") as f:
        architecture = json.load(f)

    # 2. 渲染 elements
    elements = render_architecture(architecture)

    # 3. 生成 ProcessOn pos
    now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

    pos = {
        "diagram": {
            "elements": {
                "comments": [],
                "plugins": {},
                "elements": elements,
                "page": {
                    "padding": 20,
                    "backgroundColor": "255,255,255",
                    "gridSize": 10,
                    "width": 3000,
                    "height": 2000,
                    "name": "Page-1",
                    "showGrid": True,
                    "lineJumps": True,
                    "richText": True
                },
                "version": 1
            }
        },
        "meta": {
            "exportTime": now,
            "member": "",
            "diagramInfo": {
                "creator": "",
                "created": now,
                "modified": now,
                "title": "数据中台总体架构",
                "category": "flow"
            },
            "id": "data_middle_platform_001",
            "type": "ProcessOn Schema File",
            "version": "5.0"
        }
    }

    # 4. 输出文件
    with open("data_middle_platform.pos", "w", encoding="utf-8") as f:
        json.dump(pos, f, ensure_ascii=False, indent=2)

    print("✅ 已生成 data_middle_platform.pos,可直接导入 ProcessOn")


if __name__ == "__main__":
    main()

解析图像的大小以及位置关系

系统提示词

你是一个熟练的 ProcessOn JSON 解析与生成助手。
你的任务是:根据提供的图像内容或文本描述,生成符合 ProcessOn 最小可用 JSON 格式的结构化数据。
生成要求:
1. 每个矩形或元素必须包含以下信息:
   - 唯一 id
   - 文本内容
   - 坐标信息:x、y(左上角位置)
   - 大小信息:width、height
   - 父子关系(如果矩形嵌套在另一个矩形内)
2. 所有元素按 JSON 层级结构嵌套,反映图中实际的空间布局。
3. 坐标和大小应尽量模拟原图比例关系(可以用近似值)。
4. 输出必须是合法 JSON,不允许省略任何必要字段。
5. JSON 示例格式如下:
{
  "diagram": {
    "elements": {
      "id-1": {
        "type": "rectangle",
        "text": "示例文本",
        "x": 100,
        "y": 200,
        "width": 300,
        "height": 150,
        "children": {
          "id-2": {
            "type": "rectangle",
            "text": "嵌套矩形",
            "x": 120,
            "y": 220,
            "width": 100,
            "height": 50
          }
        }
      }
    }
  }
}
请严格遵循这个格式生成 JSON。

用户提示词

请根据下面的图生成对应的 ProcessOn JSON,包含每个矩形的坐标和大小信息:
- 顶层矩形 A,位置(50, 50),大小 400x300
- 矩形 B 嵌套在 A 内,位置(70, 80),大小 150x100
- 矩形 C 顶层,位置(500, 100),大小 200x150
请生成合法 JSON。

python代码组装

import json
from datetime import datetime

# ===============================
# ProcessOn 最小稳定矩形模板(支持自定义宽高)
# ===============================
def rect_shape(id, name, text, x, y, w, h, z):
    return {
        "shapeStyle": {"alpha": 1},
        "anchors": [
            {"x": "w/2", "y": "0"},
            {"x": "w/2", "y": "h"},
            {"x": "0", "y": "h/2"},
            {"x": "w", "y": "h/2"}
        ],
        "textBlock": [
            {
                "position": {"x": 10, "y": 0, "w": "w-20", "h": "h"},
                "text": (
                    "<section>"
                    "<span style='font-size:14px;font-family:Arial;color:#000000;'>"
                    f"<b>{text}</b>"
                    "</span>"
                    "</section>"
                )
            }
        ],
        "title": "矩形",
        "fontStyle": {
            "fontFamily": "Arial",
            "size": 14,
            "color": "0,0,0",
            "textAlign": "center",
            "vAlign": "middle"
        },
        "props": {
            "x": x,
            "y": y,
            "w": w,
            "h": h,
            "zindex": z,
            "angle": 0
        },
        "path": [
            {
                "actions": [
                    {"action": "move", "x": "0", "y": "0"},
                    {"action": "line", "x": "w", "y": "0"},
                    {"action": "line", "x": "w", "y": "h"},
                    {"action": "line", "x": "0", "y": "h"},
                    {"action": "line", "x": "0", "y": "0"}
                ]
            }
        ],
        "lineStyle": {
            "lineStyle": "solid",
            "lineColor": "0,0,0",
            "lineWidth": 1
        },
        "fillStyle": {
            "color": "255,255,255",
            "type": "solid"
        },
        "children": [],
        "resizeDir": ["tl", "tr", "br", "bl"],
        "name": name,
        "category": "basic",
        "locked": False,
        "id": id,
        "attribute": {
            "container": False,
            "rotatable": True,
            "visible": True,
            "collapsable": False,
            "collapsed": False,
            "linkable": True,
            "markerOffset": 5
        }
    }

# ===============================
# 递归处理 JSON 中元素(支持嵌套)
# ===============================
def render_elements_from_json(json_elements, z_start=1):
    elements = {}
    z_index = z_start

    def traverse(ele, parent=None):
        nonlocal z_index
        eid = ele.get("id", f"id-{z_index}")
        rect = rect_shape(
            id=eid,
            name=ele.get("text", eid),
            text=ele.get("text", ""),
            x=ele.get("x", 0),
            y=ele.get("y", 0),
            w=ele.get("width", 220),
            h=ele.get("height", 60),
            z=z_index
        )
        z_index += 1

        # 递归处理 children
        children = ele.get("children", {})
        for child in children.values() if isinstance(children, dict) else children:
            child_rect = traverse(child, parent=rect)
            rect["children"].append(child_rect)

        return rect

    for ele in json_elements.values():
        elements[ele.get("id", f"id-{z_index}")] = traverse(ele)

    return elements

# ===============================
# 主入口
# ===============================
def main():
    # 1. 读取已有 JSON(包含坐标和大小)
    with open("dsl01.json", "r", encoding="utf-8") as f:
        json_data = json.load(f)

    # 2. 渲染 ProcessOn elements
    elements = render_elements_from_json(json_data["diagram"]["elements"])

    # 3. 生成 ProcessOn pos
    now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

    pos = {
        "diagram": {
            "elements": {
                "comments": [],
                "plugins": {},
                "elements": elements,
                "page": {
                    "padding": 20,
                    "backgroundColor": "255,255,255",
                    "gridSize": 10,
                    "width": 3000,
                    "height": 2000,
                    "name": "Page-1",
                    "showGrid": True,
                    "lineJumps": True,
                    "richText": True
                },
                "version": 1
            }
        },
        "meta": {
            "exportTime": now,
            "member": "",
            "diagramInfo": {
                "creator": "",
                "created": now,
                "modified": now,
                "title": "数据中台总体架构",
                "category": "flow"
            },
            "id": "data_middle_platform_001",
            "type": "ProcessOn Schema File",
            "version": "5.0"
        }
    }

    # 4. 输出 pos 文件
    with open("dsl01.pos", "w", encoding="utf-8") as f:
        json.dump(pos, f, ensure_ascii=False, indent=2)

    print("✅ 已生成 dsl01.pos,可直接导入 ProcessOn")

if __name__ == "__main__":
    main()

第三版

系统提示词

你是一个专业的图像到数据解析助手。你的任务是解析输入的图像内容,识别图中的矩形元素,并输出矩形的位置和尺寸信息。  

请严格遵守以下输出规则:
1. 输出 **纯 JSON 数组**,数组中每个元素表示一个矩形。
2. 每个矩形包含以下字段:
   - "text":矩形中的文字内容
   - "x":矩形左上角横坐标
   - "y":矩形左上角纵坐标
   - "w":矩形宽度
   - "h":矩形高度
3. 坐标和尺寸使用整数,不要包含任何单位。
4. 输出格式必须像示例一样,不要添加其他注释或字段:
[
  {"text":"示例文字","x":10,"y":20,"w":100,"h":50},
  {"text":"示例文字2","x":150,"y":20,"w":100,"h":50}
]
5. 不要输出解释、描述或额外信息,**只输出 JSON**

用户提示词

请解析这张架构图,提取所有矩形框及其文字内容和坐标信息。  
输出格式必须严格按照 JSON 数组,如下示例:

[
  {"text":"顶部","x":50,"y":20,"w":550,"h":30},
  {"text":"左侧","x":50,"y":50,"w":400,"h":300},
  {"text":"左侧嵌套","x":70,"y":80,"w":150,"h":100},
  {"text":"中间-上","x":470,"y":80,"w":120,"h":40},
  {"text":"中间中","x":470,"y":140,"w":120,"h":40},
  {"text":"中间下","x":470,"y":200,"w":120,"h":40},
  {"text":"右侧","x":500,"y":100,"w":200,"h":150}
]

只输出 JSON,不要其他解释。

python代码

import json
import uuid
from datetime import datetime


def create_pos_element(rect):
    """生成单个矩形元素的 ProcessOn pos 格式"""
    elem_id = str(uuid.uuid4())
    return {
        "shapeStyle": {"alpha": 1},
        "anchors": [
            {"x": "w/2", "y": "0"},
            {"x": "w/2", "y": "h"},
            {"x": "0", "y": "h/2"},
            {"x": "w", "y": "h/2"}
        ],
        "textBlock": [
            {
                "position": {"x": 10, "y": 0, "w": "w-20", "h": "h"},
                "text": f"<section><b>{rect['text']}</b></section>"
            }
        ],
        "title": "矩形",
        "fontStyle": {
            "fontFamily": "Arial", "size": 14, "color": "0,0,0",
            "textAlign": "center", "vAlign": "middle"
        },
        "props": {
            "x": rect["x"],
            "y": rect["y"],
            "w": rect["w"],
            "h": rect["h"],
            "zindex": 1,
            "angle": 0
        },
        "path": [
            {
                "actions": [
                    {"action": "move", "x": "0", "y": "0"},
                    {"action": "line", "x": "w", "y": "0"},
                    {"action": "line", "x": "w", "y": "h"},
                    {"action": "line", "x": "0", "y": "h"},
                    {"action": "line", "x": "0", "y": "0"}
                ]
            }
        ],
        "lineStyle": {"lineStyle": "solid", "lineColor": "0,0,0", "lineWidth": 1},
        "fillStyle": {"color": "255,255,255", "type": "solid"},
        "children": [],
        "resizeDir": ["tl", "tr", "br", "bl"],
        "name": rect["text"],
        "category": "basic",
        "locked": False,
        "id": elem_id,
        "attribute": {
            "container": False,
            "rotatable": True,
            "visible": True,
            "collapsable": False,
            "collapsed": False,
            "linkable": True,
            "markerOffset": 5
        },
        "_raw": {
            "text": rect["text"],
            "x": rect["x"],
            "y": rect["y"],
            "w": rect["w"],
            "h": rect["h"]
        }
    }


def json_to_pos(json_file, pos_file):
    with open(json_file, "r", encoding="utf-8") as f:
        rects = json.load(f)

    elements = {}
    for rect in rects:
        elem = create_pos_element(rect)
        elements[elem["id"]] = elem

    pos_data = {
        "diagram": {
            "elements": {
                "elements": elements,
                "comments": [],
                "plugins": {},
                "page": {
                    "padding": 20,
                    "backgroundColor": "255,255,255",
                    "gridSize": 10,
                    "width": 1110,
                    "height": 660,
                    "name": "Page-1",
                    "showGrid": True,
                    "lineJumps": True,
                    "richText": True
                },
                "version": 1
            }
        },
        "meta": {
            "exportTime": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
            "member": "",
            "diagramInfo": {
                "creator": "",
                "created": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
                "modified": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
                "title": "自动生成",
                "category": "flow"
            },
            "id": "auto_generated_001",
            "type": "ProcessOn Schema File",
            "version": "5.0"
        }
    }

    with open(pos_file, "w", encoding="utf-8") as f:
        json.dump(pos_data, f, ensure_ascii=False, indent=2)
    print(f"POS 文件已生成:{pos_file}")


if __name__ == "__main__":
    json_file = "dsl02.json"  # 输入 JSON 文件
    pos_file = "diagram.pos"  # 输出 POS 文件
    json_to_pos(json_file, pos_file)