In a Python script, a cursor.fetchall
command is returning a list of tuples, some elements of which are marked as e.g. Decimal('0.50')
instead of just 0.50
.
myList= [(1, 'string1', None, None, 'string2', 0, 'string3'),
(1, 'string1', Decimal('0.50'), Decimal('2.5'), 'string2', 3, 'string3')]
The reason I'd like the latter form (i.e. just 0.50
) is that I'm trying to send the list using print(json.dumps(result))
, which currently returns TypeError: Decimal('0.50') is not JSON serializable
.
Is there a direct way to strip away this "type" information? I've been turning around on this without success, and I find previous related questions only cover cases where all elements are of the same type (e.g. here). Thanks for any tips!