Skip to content Skip to sidebar Skip to footer

Convert Json To Python Object: How To Handle Datetime Conversion?

I have a C# console app that serializes a POCO class to a JSON string; I use JSON.Net for serialization. The JSON from this app is dumped to a file, and read in by a Python 2.7 scr

Solution 1:

You can specify the format you want. Try something like this:

DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'

Before serializing: time = datetime.strftime(time, DATETIME_FORMAT)

After unserializing: time = datetime.strptime(time, DATETIME_FORMAT)

Post a Comment for "Convert Json To Python Object: How To Handle Datetime Conversion?"