0

我在将 JSON 有效负载转换为所需文档时遇到了麻烦。

我有以下输入:

{
  "events": [
    {
      "recipientId": "r0001"
    },
    {
      "recipientId": "r0002"
    }
  ],
  "networkResponseTime": 1234
}

期望的输出:

{
  "events": [
    {
      "recipientIds": "r0001",
      "networkResponseTime": 1234"
    },
    {
      "recipientIds": "r0002",
      "networkResponseTime": 1234"
    }
  ]
}

这个例子的 JOLT 规范是什么样子的?

到目前为止,我有这样的东西:

[{
    "operation": "shift",
    "spec": {
      "events": {
        "*": {
          "recipientId": "events[&1].recipientIds"
        }
      }
    }
}]
4

1 回答 1

1

规格

[{
  "operation": "shift",
  "spec": {
    "events": {
      "*": {
        "recipientId": "events[&1].recipientIds",
        //
        // go back up to the root of the tree, and then 
        //  come back down the key "networkResponseTime", and
        //  send it's value to "events[&1].networkResponseTime"
        "@(2,networkResponseTime)": "events[&1].networkResponseTime"
      }
    }
  }
}]
于 2017-10-19T18:11:24.797 回答