These small helper functions give a higher level interface for constructing complex datatype definitions, while maintaining portable datatypes.
Returns a ‘choice’ dictionary of the given choices.
>>> choice('str', 'int')
{'_type_': 'choice', 'choices': ['str', 'int']}
Returns a ‘literal’ dictionary.
>>> literal('foo')
{'_type_': 'literal', 'value': 'foo'}
Returns a ‘named’ dictionary for naming the given ‘value’ datatype.
>>> named('person', {'first_name': 'str'})
{'_type_': 'named', 'name': 'person', 'value': {'first_name': 'str'}}
Returns a ‘reference’ dictionary for the given named type.
>>> reference('person')
{'_type_': 'reference', 'name': 'person'}