我试图使用Jolt转换来编写规范来转换json
输入:
{
"video": "10506207",
"id": "ef3ef821-92cb-441b-b218-c10e543398e3",
"session": "a7a55e610a813c36",
"time-in": 180,
"event": "init"
}
输出
{
"video": "10506207",
"id": "ef3ef821-92cb-441b-b218-c10e543398e3",
"session": "a7a55e610a813c36",
"events":[
"event": "init",
"time-in": 180,
"time-out": 120, (= time-in - 60)
]
}
基本上尝试两件事: 1.移动' time-in'和'事件'属于'事件'排列 2.添加超时' =时间 - 60 -
使用'默认'操作我可以添加属性但不能进行数学运算。谢谢你的帮助!
答案 0 :(得分:1)
幻想"超时=时间在-60" Jolt不支持。但它可以移动数据,使其匹配所需的输出格式,减去"超时"计算
规格
[
{
"operation": "shift",
"spec": {
"video": "video",
"id": "id",
"session": "session",
"time-in": "events[0].time-in",
"event": "events[0].event"
}
}
]