我正在尝试为下面的输入写一个jolt转换-
{
"restaurantId": "ZZ4ORJDY3E",
"chainId": "a-b"
}预期输出为-
{
"ZZ4ORJDY3E" : {
"key" : "ZZ4ORJDY3E",
"start" : "a",
"end" : "b"
}
}我的规格是-
[
{
"operation": "shift",
"spec": {
"@restaurantId": "@restaurantId.key",
"chainId": {
"*-*": {
"$(0,1)": "@restaurantId.start",
"$(0,2)": "@restaurantId.end"
}
}
}
}
]规范没有按照预期的输出进行转换。我想学习如何在字符串解析器中使用属性。
发布于 2018-01-20 01:12:01
等级库
[
{
"operation": "shift",
"spec": {
"restaurantId": {
// match any value of restaurantId
"*": {
// write the value to of the key $ to the output
// where the output is the "value of the key".key
// kinda hokey
"$": "&.key"
}
},
"chainId": {
"*-*": {
// write each part of the chainId to the output
// at the value of restaurantId from back up the tree
"$(0,1)": "@(3,restaurantId).start",
"$(0,2)": "@(3,restaurantId).end"
}
}
}
}
]https://stackoverflow.com/questions/48285655
复制相似问题