我有两个有效负载并希望将它们合并为单个 JSON 对象(流式连接)。在少数地方,人们建议使用 AttributesToJSON,但由于其中一个 JSON 没有固定的属性集,我想这是不可能的。
第一个有效载荷是
{
"title":"API-Actions Documentation",
"title_link":"https://api.slack.com/",
"author_name":"name",
"author_link":"http://flickr.com/bobby/",
"author_icon":"http://flickr.com/icons/bobby.jpg",
"text":"Optional",
"image_url":"http://my-website.com/path/to/image.jpg",
"thumb_url":"http://example.com/path/to/thumb.png",
"footer":null,
"pretext":"@name",
"color":"#7CD197"
}
Run Code Online (Sandbox Code Playgroud)
第二个是,
{
"fields":[
{
"title":"Priority",
"value":"low",
"short":"true"
},
{
"title":"Priority",
"value":"medium",
"short":"true"
},
{
"title":"Priority",
"value":"high",
"short":"true"
},
{
"title":"Priority",
"value":"blocker",
"short":"true"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我希望输出为
{
"title":"API-Actions Documentation",
"title_link":"https://api.slack.com/",
"author_name":"name",
"author_link":"http://flickr.com/bobby/",
"author_icon":"http://flickr.com/icons/bobby.jpg",
"text":"Optional",
"image_url":"http://my-website.com/path/to/image.jpg",
"thumb_url":"http://example.com/path/to/thumb.png",
"footer":null,
"pretext":"@name",
"color":"#7CD197",
"fields":[
{
"title":"Priority",
"value":"low",
"short":"true"
},
{
"title":"Priority",
"value":"medium",
"short":"true"
},
{
"title":"Priority",
"value":"high",
"short":"true"
},
{
"title":"Priority",
"value":"blocker",
"short":"true"
}
]
}
Run Code Online (Sandbox Code Playgroud)
简单!只需使用MergeContent并设置以下配置:
Merge Format: Binary Concatenation
Minimum Number of Entries: 2
Delimiter Strategy: Text
Header: [
Footer: ]
Demarcator: ,
Run Code Online (Sandbox Code Playgroud)
(你可以使用,MergeRecord但至少对我来说它有点问题)。
然后转移到JoltTrasnformJSON并设置Jolt Transformation DSL为Shift和Jolt Specification到:
{
"*": {
"*": "&"
}
}
Run Code Online (Sandbox Code Playgroud)
这应该可以完成工作:)
| 归档时间: |
|
| 查看次数: |
1053 次 |
| 最近记录: |