You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
instance: An instance of this message type, or something
compatible (accepted by the type's constructor).
use_integers_for_enums (Optional(bool)): An option that determines whether enum
values should be represented by strings (False) or integers (True).
Default is True.
Returns:
str: The json string representation of the protocol buffer.
"""
returnMessageToJson(
cls.pb(instance),
use_integers_for_enums=use_integers_for_enums,
including_default_value_fields=True,
)
Currently if you want to turn an existing message into a dict you have to go through JSON. Prompted by discussion in googleapis/python-memcache#19.
importjsonfromgoogle.cloudimportmemcache# to jsoninstance=memcache.Instance(name="projects/project/locations/location/instances/instance")
instance_json=memcache.Instance.to_json(instance)
# to dictinstance_dict=json.loads(instance_json)
I think
to_dictwould be a clone ofto_jsonthat callsMessageToDictinstead ofMessageToJson.proto-plus-python/proto/message.py
Lines 331 to 348 in cd9003c
Currently if you want to turn an existing message into a dict you have to go through JSON. Prompted by discussion in googleapis/python-memcache#19.