MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / to_json

Method to_json

mongoengine/base/document.py:442–460  ·  view source on GitHub ↗

Convert this document to JSON. :param use_db_field: Serialize field names as they appear in MongoDB (as opposed to attribute names on this document). Defaults to True.

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

440 raise ValidationError(message, errors=errors)
441
442 def to_json(self, *args, **kwargs):
443 """Convert this document to JSON.
444
445 :param use_db_field: Serialize field names as they appear in
446 MongoDB (as opposed to attribute names on this document).
447 Defaults to True.
448 """
449 use_db_field = kwargs.pop("use_db_field", True)
450 if "json_options" not in kwargs:
451 warnings.warn(
452 "No 'json_options' are specified! Falling back to "
453 "LEGACY_JSON_OPTIONS with uuid_representation=PYTHON_LEGACY. "
454 "For use with other MongoDB drivers specify the UUID "
455 "representation to use. This will be changed to "
456 "uuid_representation=UNSPECIFIED in a future release.",
457 DeprecationWarning,
458 )
459 kwargs["json_options"] = LEGACY_JSON_OPTIONS
460 return json_util.dumps(self.to_mongo(use_db_field), *args, **kwargs)
461
462 @classmethod
463 def from_json(cls, json_data, created=False, **kwargs):

Callers

nothing calls this directly

Calls 2

to_mongoMethod · 0.95
popMethod · 0.80

Tested by

no test coverage detected