def get_doc_size(doc): """ Get document size in bytes :Parameters: - `doc`: string or dict """ if not isinstance(doc, dict): doc = json.loads(doc) return len(BSON.encode(doc))
def test_data_serialization(self, data): self.load_bson() BSON.encode(data, check_keys=True)
def serialize_report(self, output_file, report_data): self.load_bson() bson_data = BSON.encode(report_data, check_keys=True) with open(output_file, "wb") as fp: fp.write(bson_data)