public static WorkflowJsonObject ParseJson(string json) { var data = JsonValue.Parse(json); var result = new WorkflowJsonObject(); result.nodes = new List <FlowNodeJsonObject>(); result.connections = new List <NodeConnectionJsonObject>(); result.labels = new List <TextLabelJsonObject>(); foreach (JsonValue node in data["nodes"]) { var nodeResult = new FlowNodeJsonObject(); nodeResult.id = node["id"]; nodeResult.name = node["name"]; nodeResult.user = node["user"]; nodeResult.role = node["role"]; nodeResult.xpos = node["xpos"]; nodeResult.ypos = node["ypos"]; nodeResult.status = node["status"]; result.nodes.Add(nodeResult); } foreach (JsonValue conn in data["connections"]) { var connResult = new NodeConnectionJsonObject(); connResult.from = conn["from"]; connResult.to = conn["to"]; connResult.label = conn["label"]; result.connections.Add(connResult); } foreach (JsonValue label in data["labels"]) { var labelResult = new TextLabelJsonObject(); labelResult.text = label["text"]; labelResult.xpos = label["xpos"]; labelResult.ypos = label["ypos"]; labelResult.centerAligned = label["centerAligned"]; labelResult.fontSize = label["fontSize"]; labelResult.fontFamily = label["fontFamily"]; result.labels.Add(labelResult); } result.id = data["id"]; return(result); }
private static Point ParsePoint(FlowNodeJsonObject node) { return(new Point(node.xpos, node.ypos)); }