Wie konvertiere ich einen String nach BSON?
Ich habe einen String wie diesen:
document = '{ time : 14/09/19 16:00:00,
global : { full:190 , defects: 7 , btp: 6 , total: 202 } ,
domains : [ { domain : "A" , full:7 , defects: 2 , btp: 0 , total: 9 },
{ domain : "B" , full:0 , defects: 0 , btp: 0 , total: 0 },
{ domain : "C" , full:6 , defects: 0 , btp: 0 , total: 6 },
{ domain : "D" , full:26 , defects: 0 , btp: 2 , total: 28 },
{ domain : "E" , full:0 , defects: 0 , btp: 0 , total: 0 },
{ domain : "F" , full:4 , defects: 0 , btp: 2 , total: 6 },
{ domain : "G" , full:0 , defects: 0 , btp: 0 , total: 0 },
{ domain : "H" , full:21 , defects: 0 , btp: 1 , total: 22 },
{ domain : "I" , full:32 , defects: 0 , btp: 0 , total: 32 },
] }'
Wenn ich versuche, dies in eine mongoDB-Auflistung einzufügen, wird der folgende Fehler angezeigt:
TypeError: Objekt 'str' unterstützt keine Elementzuweisung
ch weiß nicht, wie ich einen String nach BSON konvertieren soll, um die Einfügung damit auszuführe
Ich sah in derbson_util
Modul, aber kein Glück.