Jolt JSON 从 String 值到 Long 的转换
Jolt JSON Conversion from String value to Long
我正在使用 Jolt 将一个 json 转换为另一个 json。一切正常,除了我想将 String 值转换为 Long。以下是我的规格和输入。我使用了 modify-overwrite-beta 但运气不好。
Specs -
[
{
"operation": "modify-overwrite-beta",
"spec": {
"timestamp": "=toLong(@(1,time))"
}
},
{
"operation": "shift",
"spec": {
"key1": "outputText1",
"key2": "outputText2",
"key3": "outputText3",
"time": "timestamp"
}
}
]
Input Json
{
"key1": "test1",
"time": "1499967627",
"key2": "test2",
"key3": "test3",
}
所以在上面的输入 json 中,我如何将 time 值转换为 Long
预计 Json:
{
"outputText1": "test1",
"timestamp": 1499967627,
"outputText2": "test2",
"outputText3": "test3",
}
规格
[
{
"operation": "modify-overwrite-beta",
"spec": {
"timestamp": "=toLong(@(1,time))"
}
},
{
"operation": "shift",
"spec": {
"key1": "outputText1",
"key2": "outputText2",
"key3": "outputText3",
// pass timestamp thru
"timestamp": "timestamp"
}
}
]
在第一个操作(修改)中,它使 "timestamp" 变长。但是在第二个操作中,您将字符串值从 "time" 复制到时间戳,而不是通过时间戳。
我正在使用 Jolt 将一个 json 转换为另一个 json。一切正常,除了我想将 String 值转换为 Long。以下是我的规格和输入。我使用了 modify-overwrite-beta 但运气不好。
Specs -
[
{
"operation": "modify-overwrite-beta",
"spec": {
"timestamp": "=toLong(@(1,time))"
}
},
{
"operation": "shift",
"spec": {
"key1": "outputText1",
"key2": "outputText2",
"key3": "outputText3",
"time": "timestamp"
}
}
]
Input Json
{
"key1": "test1",
"time": "1499967627",
"key2": "test2",
"key3": "test3",
}
所以在上面的输入 json 中,我如何将 time 值转换为 Long
预计 Json:
{
"outputText1": "test1",
"timestamp": 1499967627,
"outputText2": "test2",
"outputText3": "test3",
}
规格
[
{
"operation": "modify-overwrite-beta",
"spec": {
"timestamp": "=toLong(@(1,time))"
}
},
{
"operation": "shift",
"spec": {
"key1": "outputText1",
"key2": "outputText2",
"key3": "outputText3",
// pass timestamp thru
"timestamp": "timestamp"
}
}
]
在第一个操作(修改)中,它使 "timestamp" 变长。但是在第二个操作中,您将字符串值从 "time" 复制到时间戳,而不是通过时间戳。