CodyIT@programming.dev to Programmer Humor@programming.devEnglish · 15 days agoEveryone's asking, 'Who's Json?', but nobody's asking, 'How's Json?'programming.devimagemessage-square132linkfedilinkarrow-up11
arrow-up11imageEveryone's asking, 'Who's Json?', but nobody's asking, 'How's Json?'programming.devCodyIT@programming.dev to Programmer Humor@programming.devEnglish · 15 days agomessage-square132linkfedilink
minus-square_stranger_@lemmy.worldlinkfedilinkarrow-up0·15 days agoI would have accepted this answer. I was hoping for json.dumps, but that’ll work.
minus-squaremel ♀@jlai.lulinkfedilinkarrow-up0·14 days agoI think json.dumps would not work if there is a datetime in the dict, right?
minus-square_stranger_@lemmy.worldlinkfedilinkarrow-up0·14 days agoYeah there’s other edge cases too, like Decimal, but as long as you have those things imported when you send it through dumps it should work.
minus-squaremel ♀@jlai.lulinkfedilinkarrow-up0·14 days agoJust tried it in an ipython shell import datetime import json json.dumps({"a": datetime.datetime(1970,1,1)}) And I got the TypeError: datetime not JSON serializable though.
I would have accepted this answer.
I was hoping for json.dumps, but that’ll work.
I think json.dumps would not work if there is a datetime in the dict, right?
Yeah there’s other edge cases too, like Decimal, but as long as you have those things imported when you send it through dumps it should work.
Just tried it in an ipython shell
import datetime import json json.dumps({"a": datetime.datetime(1970,1,1)})And I got the TypeError: datetime not JSON serializable though.