【发布时间】:2021-02-11 06:02:05
【问题描述】:
我想将 JSON 转换为 YAML。我想在Java中动态地做到这一点。基于componentId,属性会改变。这个 JSON 可以变化并支持多个 componentId,这来自 HTTP 请求。
示例 JSON:
[
{
"id": "timer",
"attributes": {
"type": "tick"
"period": "5000"
},
"output": "transform"
},
{
"id": "transform",
"attributes": {
"expression": "${body.toUpperCase()}”,
“type”: “simple"
},
"output": "log"
},
{
"id": "log",
"attributes": {
"message": "hello world”,
“type”: “info"
}
}
]
预期的 YAML:
- from:
uri: "timer:tick"
parameters:
period: "5000"
steps:
- set-body:
constant: "Hello Yaml!!!"
- transform:
simple: "${body.toUpperCase()}"
- to: "log:info”
【问题讨论】:
-
这能回答你的问题吗? Convert JSON to YAML. Parsing JSON to YAML
-
能否分享完整的 JSON?