使用震动转换创建新属性

时间:2018-10-22 09:45:08

标签: jolt

我尝试转型

{
  "name": "bla",
  "latitude": 1,
  "longitude": 2
}

进入

{
  "name": "bla",
  "location": {
     "latitude": 1,
     "longitude": 2
  }
}

具有以下移位操作

[
  {
    "operation": "shift",
    "spec": {
      "name": "name",
      "location": {
        "latitude": "&1.latitude",
        "longitude": "&1.longitude"
      },
    }
  }
]

但是,它只是创建名称字段。有什么想法可以创建位置属性吗?

1 个答案:

答案 0 :(得分:0)

[
  {
    "operation": "shift",
    "spec": {
      "name": "name",
      "latitude": "location.latitude",
      "longitude": "location.longitude"
    }
  }
]

通过阅读Jolt Transform DSL文档https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Shiftr.java

找到了解决方案