Preserving default value of a method parameter when passing a non existing property of a JSON object
Hi,
I have a method that has multiple parameters and is normally used from other classes in ObjectScript. Most of the parameters have default values. Withing the server code that's perfect. In some areas I can call myMethod(,,"sometext") or myMethod(tVariab) and thats fine... I use it as it's required in each place.
But now I want to expose it as a REST service so I need to buld a kind of wrapper., another method in a REST dispatcher class that will receive the parameters in a JSON object and will call the server method already implemented. Something like:
{"par1":1111, "par2":"sample text", "par3":0}
that is transformed to a tJSON %DynamicObject that later will be used to call the method: myMethod(tJSON.par1,tJSON.par2,tJSON.par3) ... so far so good.
BUT, I hoped that it would be posible to receive:
{"par1:2222} and then run myMethod(tJSON.par1,tJSON.par2,tJSON.par3)... and, as par2 and par3 really don't exist this time, I expected myMethod assume default values for par2 and par3 parameters. But, in the end, IRIS assumes that I'm passing "" in those positions as if call statement was: myMethod(2222,"","") instead of myMethod(2222).
I want to avoid to implement in the wrapper all possible combinations of input parameters... which would be the best approach?