{"id":16383323,"url":"https://github.com/nicolaiarocci/json-datetime","last_synced_at":"2025-03-21T02:30:53.683Z","repository":{"id":4517557,"uuid":"5657413","full_name":"nicolaiarocci/json-datetime","owner":"nicolaiarocci","description":"Decoding of datetime values contained in JSON streams. A wrapper around simplejson `loads` method.","archived":false,"fork":false,"pushed_at":"2022-12-09T15:22:28.000Z","size":17,"stargazers_count":13,"open_issues_count":6,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T19:52:09.251Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicolaiarocci.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-03T10:12:56.000Z","updated_at":"2021-07-21T00:44:07.000Z","dependencies_parsed_at":"2023-01-13T13:08:46.738Z","dependency_job_id":null,"html_url":"https://github.com/nicolaiarocci/json-datetime","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolaiarocci%2Fjson-datetime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolaiarocci%2Fjson-datetime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolaiarocci%2Fjson-datetime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolaiarocci%2Fjson-datetime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicolaiarocci","download_url":"https://codeload.github.com/nicolaiarocci/json-datetime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244725433,"owners_count":20499596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T04:07:59.619Z","updated_at":"2025-03-21T02:30:53.399Z","avatar_url":"https://github.com/nicolaiarocci.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"JSON-datetime\n=============\n.. image:: https://secure.travis-ci.org/nicolaiarocci/json-datetime.png?branch=master\n        :target: https://secure.travis-ci.org/nicolaiarocci/json-datetime\n\nJSON-datetime allows for proper decoding of datetime values contained in JSON\nstreams.\n\nThe problem\n-----------\nThe JSON standard RFC 4627 does not\nsupport datetime types. These are usually represented as strings and Python \ndecoders end up decoding them as such. Consider the following example:\n\n.. code-block:: python\n\n    import simplejson as json\n\n    \u003e\u003e\u003e test = '{\"name\": \"John Doe\", \"born\": \"Thu, 1 Mar 2012 10:00:49 UTC\"}'\n    \u003e\u003e\u003e json.loads(test)\n    {'born': u'Thu, 1 Mar 2012 10:00:49 UTC', 'name': u'John Doe'}\n\nAs you can see, in the resulting dictionary ``born`` is still a string.\n\nThe solution\n------------\nJSON-datetime is a very simple wrapper around Python simplejson ``loads`` \nmethod. It decodes datetime values contained in JSON strings: \n\n.. code-block:: python\n\n    import jsondatetime as json\n\n    \u003e\u003e\u003e test = '{\"name\": \"John Doe\", \"born\": \"Thu, 1 Mar 2012 10:00:49 UTC\"}'\n    \u003e\u003e\u003e json.loads(test)\n    {'name': 'John Doe', 'born': datetime.datetime(2012, 3, 1, 10, 0 ,49)}\n\nStrings are parsed using ``dateutil.parser.parse`` which is fairly flexible for\ncommon datetime formats\n\nCustom parsing\n--------------\nBeing just a wrapper around the ``loads`` method, you can still use all the\nstandard ``loads`` arguments, ``object_hook`` included. This means that you can\nstill perform custom parsing of your inbound JSON stream.\n\nInstallation\n------------\n``pip install json-datetime``\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolaiarocci%2Fjson-datetime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicolaiarocci%2Fjson-datetime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolaiarocci%2Fjson-datetime/lists"}