In my code, a Decimal like this, where aDecimal is Class Decimal.
Decimal
aDecimal
try? JSONEncoder().encode(aDecimal)