Addition in JMESPath

Hello! I have a query that in JMESPath can we add values in the syntax:
“AssignedIdentification_01”: "&{index} ",
“AssignedIdentification_01”: “&{index} + 1”,

I want to add 1 as the index after using the structure accessor starting from 0.

Hi @fahadmicro

Unfortunately, there is no way to do the addition directly in the JSON object editor. But you can use Value Setter to create the property AssignedIdentification_01 and assign it with &{index} as the value.

Then, in the same configuration of the Value Setter, you can add a mapper called “Prepared Operator”. Select “Addition” as the operator and set the “Left” as a number with 1 as the value. Please give it a try.

I just found out that we can also do it with JMESPath. We can use the JMESPath built-in function sum to do that. In your case, the syntax should be &{sum([to_number(index), ``1``])}.

1 Like

@Gugi Thank You. It worked perfectly