in spring-ai-alibaba-jmanus/src/main/java/com/alibaba/cloud/ai/example/manus/recorder/entity/PlanExecutionRecord.java [247:299]
public String toJson() {
StringBuilder json = new StringBuilder();
json.append("{");
// 基本信息
appendField(json, "id", id, true);
appendField(json, "planId", planId, true);
appendField(json, "title", title, true);
appendField(json, "userRequest", userRequest, true);
// 时间信息
if (startTime != null) {
appendField(json, "startTime", startTime.toString(), true);
}
if (endTime != null) {
appendField(json, "endTime", endTime.toString(), true);
}
// 执行状态
appendField(json, "currentStepIndex", currentStepIndex, false);
appendField(json, "completed", completed, false);
appendField(json, "summary", summary, true);
// 步骤信息
if (steps != null && !steps.isEmpty()) {
json.append("\"steps\":[");
for (int i = 0; i < steps.size(); i++) {
if (i > 0)
json.append(",");
json.append("\"").append(escapeJson(steps.get(i))).append("\"");
}
json.append("],");
}
// 智能体执行记录
if (agentExecutionSequence != null && !agentExecutionSequence.isEmpty()) {
json.append("\"agentExecutionSequence\":[");
for (int i = 0; i < agentExecutionSequence.size(); i++) {
if (i > 0)
json.append(",");
json.append(agentExecutionSequence.get(i).toJson());
}
json.append("],");
}
// 移除末尾多余的逗号
if (json.charAt(json.length() - 1) == ',') {
json.setLength(json.length() - 1);
}
json.append("}");
return json.toString();
}