Linked Questions

27 votes
5 answers
50k views

EDIT This question is not a duplicate of How to overcome "datetime.datetime not JSON serializable"? Because, although this is the same problem, it provides a specific context: Django. And so,...
Praveen Singh Yadav's user avatar
22 votes
2 answers
65k views

I have a class in Python for retrieving all the columns in a table and return a JSON with this data. The problem is at least one of those columns is a datetime and I can't seem to understand how to ...
Bruno Fernandes's user avatar
14 votes
1 answer
38k views

this is my code, query Notification.create_time result = session.query( Notification.content, cls.is_read, Notification.create_time).join( cls, Notification.id == cls....
max's user avatar
  • 317
0 votes
1 answer
24k views

How do I convert Python DateTime in JSON format? input from datetime import datetime my_date = datetime.now() output { "start_date": '2020-05-06T09:27:51.386383' }
rmaleki's user avatar
  • 782
3 votes
3 answers
15k views

I need an efficient way to write files containing dictionaries including datetime, and then be able to read them as dicts. Dicts like these: my_dict = {'1.0': [datetime.datetime(2000, 1, 1, 0, 0, 0, ...
Aminoff's user avatar
  • 727
2 votes
2 answers
3k views

I am trying to return an outfit from m RDS database. The dte fields are all formatted in DATETIME which is causing me to get the following error: TypeError: datetime.datetime(2012, 8, 8, 21, 46, 24, ...
user3024827's user avatar
  • 1,258
2 votes
0 answers
560 views

I'm using Python 3.6.2 with Flask and PyMongo and I'm currently saving my data (example: Admin-Object) to MongoDB as follows: Admin Class: class Admin(object): def __init__(self, email, password,...
Pascal's user avatar
  • 1,761
1 vote
0 answers
186 views

I try to save my data (type list of dictionaries) in a json file but this error was raised. for i in range(0,len(data_sentences)): data_dic = {} data_dic["sentence"] = data_sentences[i] ...
Yingqiang Gao's user avatar
0 votes
1 answer
140 views

I'm simply trying to convert a date-string to a date: import datetime exampleDate = 'Jul 8 2021' datetime.datetime.strptime(exampleDate, '%b %d %Y') However, I'm later outputting this to a json, and ...
DiamondJoe12's user avatar
  • 1,839
1534 votes
32 answers
1.4m views

So what I'm looking for here is something like PHP's print_r function. This is so I can debug my scripts by seeing what's the state of the object in question.
fuentesjr's user avatar
  • 52.5k
490 votes
18 answers
416k views

How does one convert a django Model object to a dict with all of its fields? All ideally includes foreign keys and fields with editable=False. Let me elaborate. Let's say I have a django model like ...
Zags's user avatar
  • 41.9k
430 votes
12 answers
924k views

I am writing a program that stores data in a dictionary object, but this data needs to be saved at some point during the program execution and loaded back into the dictionary object when the program ...
AJ00200's user avatar
  • 17.5k
414 votes
13 answers
225k views

I want to send a datetime.datetime object in serialized form from Python using JSON and de-serialize in JavaScript using JSON. What is the best way to do this?
user avatar
53 votes
13 answers
63k views

I have a string representation of a JSON object. dumped_dict = '{"debug": false, "created_at": "2020-08-09T11:24:20"}' When I call json.loads with this object; json.loads(dumped_dict) I get; {'...
Ozgur Vatansever's user avatar
66 votes
6 answers
78k views

The regular way of JSON-serializing custom non-serializable objects is to subclass json.JSONEncoder and then pass a custom encoder to json.dumps(). It usually looks like this: class CustomEncoder(json....
leonsas's user avatar
  • 4,948

15 30 50 per page
1
2 3 4 5 6