docs: def dump(val, humanread = True, dumpextra = False, typeinfo = DUMPTYPE_FLAT, ordered=True,
           tostr=False, encoding='utf-8'):
      '''
      Convert a parsed NamedStruct (probably with additional NamedStruct as fields) into a
      JSON-friendly format, with only Python primitives (dictionaries, lists, bytes, integers etc.)
      Then you may use json.dumps, or pprint to further process the result.
      
      :param val: parsed result, may contain NamedStruct
      
      :param humanread: if True (default), convert raw data into readable format with type-defined formatters.
              For example, enumerators are converted into names, IP addresses are converted into dotted formats, etc.
               
      :param dumpextra: if True, dump "extra" data in '_extra' field. False (default) to ignore them.
      
      :param typeinfo: Add struct type information in the dump result. May be the following values:
      
        DUMPTYPE_FLAT ('flat')
          add a field '_type' for the type information (default)
        
        DUMPTYPE_KEY ('key')
          convert the value to dictionary like: {'<struc_type>': value}
        
        DUMPTYPE_NONE ('none')
          do not add type information
      
      :param tostr: if True, convert all bytes to str
      
      :param encoding: if tostr=`True`, first try to decode bytes in `encoding`. If failed, use `repr()` instead.
      
      :returns: "dump" format of val, suitable for JSON-encode or print.
      '''
      dumped = _dump(val, humanread, dumpextra, typeinfo, ordered)
      if tostr:
          dumped = _to_str(dumped, encoding, ordered)
      return dumped