3

Input,

 {"scores": [  4,2,8,7,5  ] }

Output,

 {"FirstElement": 2 } //This is generated by dividing the first element of the array by 2.

Spec,

 [{
 "operation": "modify-overwrite-beta",
 "spec": {
    "Avg": "=divide(=firstElement(@(1,scores)),2)"
  }
}]

From the above Spec,I am trying to divide the first element of the list by 2 but the output I get is same as the input.

1 Answers1

3

Can't nest "functions" with modify. Have to break it up into two steps.

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "firstElement": "=firstElement(@(1,scores))"
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "Avg": "=divide(@(1,firstElement),2)"
    }
  }
]
Milo S
  • 4,466
  • 1
  • 19
  • 22