CodyIT@programming.devcake to Programmer Humor@programming.devEnglish · 2 months agoEveryone's asking, 'Who's Json?', but nobody's asking, 'How's Json?'programming.devimagemessage-square133linkfedilinkarrow-up11arrow-down10
arrow-up11arrow-down1imageEveryone's asking, 'Who's Json?', but nobody's asking, 'How's Json?'programming.devCodyIT@programming.devcake to Programmer Humor@programming.devEnglish · 2 months agomessage-square133linkfedilink
minus-square_stranger_@lemmy.worldlinkfedilinkarrow-up0·2 months agoI would have accepted this answer. I was hoping for json.dumps, but that’ll work.
minus-squaremel ♀@jlai.lulinkfedilinkarrow-up0·2 months agoI think json.dumps would not work if there is a datetime in the dict, right?
minus-square_stranger_@lemmy.worldlinkfedilinkarrow-up0·2 months 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·2 months 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.