I couldn't find a way to make an optional field with pyasn1. For example, I have a field "name" that is optional:
Person ::= SEQUENCE { name OCTET STRING OPTIONAL }
How can I make it in pyasn1?
class Person(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('name', univ.OctetString()), )
Any help would be really appreciated.
Hi,
try
class Person(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('name', univ.OctetString()), )
Thank you very much! It worked =)
Log in to post a comment.
I couldn't find a way to make an optional field with pyasn1.
For example, I have a field "name" that is optional:
Person ::= SEQUENCE {
name OCTET STRING OPTIONAL
}
How can I make it in pyasn1?
class Person(univ.Sequence):
componentType = namedtype.NamedTypes(
namedtype.NamedType('name', univ.OctetString()),
)
Any help would be really appreciated.
Hi,
try
class Person(univ.Sequence):
componentType = namedtype.NamedTypes(
namedtype.OptionalNamedType('name', univ.OctetString()),
)
Thank you very much!
It worked =)