New submission from Daniel Goldman <goldman.in...@gmail.com>: I encountered JavaScript-style Date objects in a JSON document that I wanted to parse, and these objects were causing the Python JSON decoder to raise an error with a message that said "Expecting object," followed by the line and column numbers. Here is an example of how such an object appeared in the document:
"someDate": new Date(1207568200000), I went looking in the documentation for a way to plug in a "fall-back" method, to be used when the module's standard conversion methods fail, but none of the supplied hooks seemed appropriate. It would be enormously helpful to provide a hook for such a method in the JSON decoder in a future release of Python. I believe this would parallel the JSON encoder's "default" keyword argument. In this way, developers could provide their own method of handling non-standard values in JSON documents. Ultimately, to parse the Date objects, I created a function similar to those in the json.decoder module, added the function to the json.decoder.ANYTHING list, and assigned a new Scanner object with this updated list to json.decoder.JSONScanner. I couldn't find a similar issue in the issues list, but my apologies if this has already been suggested. ---------- components: Library (Lib) messages: 95994 nosy: dhgoldman severity: normal status: open title: Allow for a default method in the JSON decoder type: feature request versions: Python 2.7, Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7444> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com