code: def match_jsonhook2result(hook, res, match):
      """Evaluate a hook's result match definition against a concrete result
  
      A match definition is a dict that can contain any number of keys. For each
      key it is tested, if the value matches the one in a given result.
      If all present key/value pairs match, the hook is executed. In addition to
      ``==`` tests, ``in``, ``not in``, and ``!=`` tests are supported. The
      test operation can be given by wrapping the test value into a list, the
      first item is the operation label 'eq', 'neq', 'in', 'nin'; the second value
      is the test value (set). Example::
  
          {
            "type": ["in", ["file", "directory"]],
            "action": "get",
            "status": "notneeded"
          }
  
      If a to be tested value is a list, an 'eq' operation needs to be specified
      explicitly in order to disambiguate the definition.
  
      Parameters
      ----------
      hook : str
        Name of the hook
      res : dict
        Result dictionary
      match : dict
        Match definition (see above for details).
  
      Returns
      -------
      bool
        True if the given result matches the hook's match definition, or
        False otherwise.
      """
      for k, v in match.items():
          # do not test 'k not in res', because we could have a match that
          # wants to make sure that a particular value is not present, and
          # not having the key would be OK in that case
  
          # in case the target value is an actual list, an explicit action 'eq'
          # must be given
          action, val = (
              (v[0], v[1]) if isinstance(v, list) else ("eq", v)
          )
          if action == "eq":
              if k in res and res[k] == val:
                  continue
          elif action == "neq":
              if k not in res or res[k] != val:
                  continue
          elif action == "in":
              if k in res and res[k] in val:
                  continue
          elif action == "nin":
              if k not in res or res[k] not in val:
                  continue
          else:
              lgr.warning(
                  "Unknown result comparison operation %s for hook %s, skipped",
                  action,
                  hook,
              )
          # indentation level is intended!
          return False
      return True
  
imports: import logging
  import json
  from datalad.support.exceptions import CapturedException
label_desc: Use image node_id 2 for calling a global function with example usage: match_jsonhook2result(hook, res, match) and returns: True, False