MCPcopy
hub / github.com/danielgtaylor/python-betterproto / from_json

Method from_json

src/betterproto/__init__.py:1671–1690  ·  view source on GitHub ↗

A helper function to return the message instance from its JSON representation. This returns the instance itself and is therefore assignable and chainable. This is equivalent to:: return message.from_dict(json.loads(value)) Parameters -----------

(self: T, value: Union[str, bytes])

Source from the content-addressed store, hash-verified

1669 )
1670
1671 def from_json(self: T, value: Union[str, bytes]) -> T:
1672 """A helper function to return the message instance from its JSON
1673 representation. This returns the instance itself and is therefore assignable
1674 and chainable.
1675
1676 This is equivalent to::
1677
1678 return message.from_dict(json.loads(value))
1679
1680 Parameters
1681 -----------
1682 value: Union[:class:`str`, :class:`bytes`]
1683 The value to pass to :func:`json.loads`.
1684
1685 Returns
1686 --------
1687 :class:`Message`
1688 The initialized message.
1689 """
1690 return self.from_dict(json.loads(value))
1691
1692 def to_pydict(
1693 self, casing: Casing = Casing.CAMEL, include_default_values: bool = False

Calls 1

from_dictMethod · 0.95