I need to pass a dynamic variable as a number and not as a string

There is a workaround you could try which is to use a custom formatter.

You would need to write some PHP to take the values as parameters and then make the array structure before returning the array to SC but it shouldn't be too difficult