Add dictionary methods to docs
This commit is contained in:
@@ -199,6 +199,24 @@ The only tricky one is unions, where you need to call `.which()` to determine th
|
|||||||
print('self employed')
|
print('self employed')
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
Dictionaries
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Converting to a dictionary
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
There is a convenience method for converting Cap'n Proto messages to a dictionary. This works for both Builder and Reader type messages::
|
||||||
|
|
||||||
|
alice.to_dict()
|
||||||
|
|
||||||
|
Reading froma dictionary
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
There is a convenience method for reading for reading a dict in and building a Builder message out of it. This the inverse of `Converting to a dictionary`_::
|
||||||
|
|
||||||
|
my_dict = {'name' : 'alice'}
|
||||||
|
alice = addressbook.Person.from_dict(my_dict)
|
||||||
|
|
||||||
Full Example
|
Full Example
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user