Nicht Deserialisieren PyMongo ObjectId aus JSON

Ich bin scheinbar nicht in der Lage zu Deserialisieren meine MongoDB JSON-Dokument mit dem BSON -json_util.

Json.Lasten-Funktion ist erstickt an der ObjectId() string. Ich hatte verstanden json_util in der Lage Umgang mit MongoDB die ObjectId-format und die Umwandlung in nutzbare JSON.

Python-code:

import json    
from bson import json_util

s = "{u'_id': ObjectId('4ed559abf047050c58000000')}"
u = json.loads(s, object_hook=json_util.object_hook)

Bekomme ich die decoder Ausnahme:

...
    u = json.loads(s, object_hook=json_util.object_hook)
  File "\python27\lib\json\__init__.py", line 339, in loads
    return cls(encoding=encoding, **kw).decode(s)
  File "\python27\lib\json\decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "\python27\lib\json\decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 1 column 1 (char 1)

Bin ich etwas fehlt?

InformationsquelleAutor jdev | 2011-12-07
Schreibe einen Kommentar