我正在尝试将输入json的一个值映射到输出json的哈希表,并且还希望使用jolt json转换将值保存到另一个键
输入json:
{
"metadata": "/a=value1/b=value2/c=value3"
}
规格:
[{
"operation": "shift",
"spec": {
"metadata": {
// match exactly sets of key value pairs
"/*/*/*": {
// pull each one off and accumulate them into a temp array
"$(0,1)": "temp[]",
"$(0,2)": "temp[]",
"$(0,3)": "temp[]"
}
}
}
},
{
"operation": "shift",
"spec": {
"temp": {
"*": {
// match each item by ":" into two captures
"*=*": {
"$(0,2)": "data.&(1,1)"
}
}
}
}
}
]
输出
{
"data" : {
"a" : "value1",
"b" : "value2",
"c" : "value3"
}
}
而我也想将字符串元数据映射到originalData 预期输出:
{
"data" : {
"a" : "value1",
"b" : "value2",
"c" : "value3"
},
"originalData":"/a=value1/b=value2/c=value3"
}
答案 0 :(得分:0)
规格
[
{
"operation": "shift",
"spec": {
"metadata": {
"@": "originalData",
// match exactly sets of key value pairs
"/*/*/*": {
// pull each one off and accumulate them into a temp array
"$(0,1)": "temp[]",
"$(0,2)": "temp[]",
"$(0,3)": "temp[]"
}
}
}
},
{
"operation": "shift",
"spec": {
"originalData": "originalData", // passthru
"temp": {
"*": {
// match each item by ":" into two captures
"*=*": {
"$(0,2)": "data.&(1,1)"
}
}
}
}
}
]
答案 1 :(得分:0)
Vergin