This page will explain how to construct a parser and how to use that parser.
Currently Katydid supports several parsers:
protobuf
json
reflected go structures
xml
A parser parses a specific serialization format or other parsable text or bytes. We need to put our unparsed text, bytes or other structure into a parser so that it can be validated by katydid.
We can also construct a protocol buffer parser.
We can even construct a parser for a reflected go structure.
If you want to use a parser for you own use case, here is a simple walk function.
We should always first call the Next method and check the error, to see if we have reached the end of the list of fields. Then we can retrieve a field value or field name, which can be of type int, double, uint, string, bytes or a bool. Lastly we can check whether the current position is a terminating leaf in the tree or if we can go down the tree and finally come back up. Please see the godoc for the parser.Interface and parser.Value.