0

我试图用 Jolt 在 Json Array 中求和,但我没有成功。

这是我的 json :

[
  {
"times-entries": {
  "offset": 0,
  "time_entries": [
    {
      "hours": 1
    },
    {
      "hours": 2
    }
  ]
}}]

这就是我所期望的:

{“总和小时”:3}

所以你知道我该怎么做吗?

4

1 回答 1

0

规格

[
  {
    "operation": "shift",
    "spec": {
      "0": {
        "times-entries": {
          "time_entries": {
            "*": {
              // match down to hours, write the value to the 
              //  output as an array
              "hours": "hoursAccumulator[]"
            }
          }
        }
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "sum_hours": "=intSum(@(1,hoursAccumulator))"
    }
  }
]
于 2017-12-07T03:18:55.433 回答