通过Jolt json转换,是否可以将值复制到两个不同的属性中? [英] With Jolt json transformation, is it possible to copy a value into two different attributes?
本文介绍了通过Jolt json转换,是否可以将值复制到两个不同的属性中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过Jolt转换进行一些非常简单的操作,但是却很难使其正常工作.
Am trying something very simple with Jolt transformation but struggling to get it to work.
如果我输入类似:
{
"id": "54436001"
}
我希望输出为:
{
"mediaId" : "54436001",
"events" : {
"mediaId" : "54436001"
}
}
将值复制到两个不同的属性.我很想尝试像这样的规范,但是显然不是因为重复的密钥.
Which is copying a value to two different attributes. I would be tempted to try spec like this to work, but obviously it doesn't because of duplicate key.
[
{
"operation": "shift",
"spec": {
"id": "mediaId",
"id": "events.mediaId"
}
}
]
Jolf变换有可能吗?
Is this possible with Jolf transformation?
推荐答案
是
规格
[
{
"operation": "shift",
"spec": {
"id": ["mediaId", "events.mediaId"]
}
}
]
这个想法是,如果您想移位以将一个值写入输出中的两个位置,请使用规范右侧的一个数组.
The idea is if you want shift to write a value to two locations in the output, use an array on the right hand side of the spec.
这篇关于通过Jolt json转换,是否可以将值复制到两个不同的属性中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文