JSON 整理与类型生成可运行案例
流水线运行:递归排序对象字段并保留数组顺序
递归按键名整理对象,便于人工检查。pipelines 的数组顺序不变;排序后的 JSON 文本不能直接当作通用签名规范或所有语言一致的 canonical JSON。
试一试
在完整工具中打开 ↗示例工作台
JSON 整理与类型生成
pretty键排序运行结果
{
"data": {
"pipelines": [
{
"durationSeconds": 42,
"execution": {
"jobs": [
"compile"
],
"runner": "demo-runner-a"
},
"name": "演示构建流水线",
"passed": true,
"pipelineId": "demo-pipelines-1",
"stage": "build"
},
{
"durationSeconds": 95,
"execution": {
"jobs": [
"unit",
"integration"
],
"runner": "demo-runner-b"
},
"name": "演示测试流水线",
"passed": false,
"pipelineId": "demo-pipelines-2",
"stage": "test"
}
],
"summary": {
"note": null,
"total": 2
}
},
"ok": true
}原例已核验,可修改输入后重新运行。
⌘ / Ctrl + Enter 运行01
场景与操作说明
流水线状态需要结合阶段和作业终态判断。此页面只比较运行样本,不触发构建、测试或部署。
durationSeconds 采用秒,与日志中的毫秒字段比较前需换算。
- 核对 流水线运行 的字段层级,保留 pipelineId 的字符串类型。
- 修改一项输入并运行,观察结果中的值或路径如何变化。
- 载入对照样本,复现下面的变化;恢复原例会替换当前输入。
02
对照样本
对照样本反转 pipelines 数组。字段排序不会把数组自动排回去,核对输出中的首条 pipelineId。
查看对照输入
{
"ok": true,
"data": {
"pipelines": [
{
"pipelineId": "demo-pipelines-2",
"name": "演示测试流水线",
"durationSeconds": 95,
"passed": false,
"stage": "test",
"execution": {
"runner": "demo-runner-b",
"jobs": [
"unit",
"integration"
]
}
},
{
"pipelineId": "demo-pipelines-1",
"name": "演示构建流水线",
"durationSeconds": 42,
"passed": true,
"stage": "build",
"execution": {
"runner": "demo-runner-a",
"jobs": [
"compile"
]
}
}
],
"summary": {
"total": 2,
"note": null
}
}
}对照样本的实际结果
{
"data": {
"pipelines": [
{
"durationSeconds": 95,
"execution": {
"jobs": [
"unit",
"integration"
],
"runner": "demo-runner-b"
},
"name": "演示测试流水线",
"passed": false,
"pipelineId": "demo-pipelines-2",
"stage": "test"
},
{
"durationSeconds": 42,
"execution": {
"jobs": [
"compile"
],
"runner": "demo-runner-a"
},
"name": "演示构建流水线",
"passed": true,
"pipelineId": "demo-pipelines-1",
"stage": "build"
}
],
"summary": {
"note": null,
"total": 2
}
},
"ok": true
}