I have below:
inputRecords = [{'parameter': Decimal('-0.9'), 'timestamp': datetime.datetime(2020, 3, 11, 12, 16, 48), 'epoch': 1583929008}]
I need to convert it to:
{
"parameter":-0.9,
"timestamp":"2020-03-11 12:16:48",
"epoch":1583929008
}
What I have done (default=str due to else it complains it is not serializable)
records_json = json.dumps(inputRecords, default=str)
Faulty output(parameter value becomes a STRING when it needs to be a NUMBER:
{
"parameter":"-0.9",
"timestamp":"2020-03-11 12:16:48",
"epoch":1583929008
}
Any suggestion how I can solve this in a clean and simple way?