This is what we eventually used. First we converted the Decimal to a String and then we stripped the trailing zeros with the following RegEx:
s = s.indexOf(".") < 0 ? s : s.replaceAll("0*$", "").replaceAll("\\.$", "");
Use format decimal to format the decimal into a string with the amount of decimal places. https://world.mendix.com/plugins/servlet/mobile#content/view/9535772