def _register_json_primitive(object_type, encoder, decoder):
  """Extend what Pipeline can serialize.

  Args:
    object_type: type of the object.
    encoder: a function that takes in an object and returns
      a dict of json primitives.
    decoder: inverse function of encoder.
  """
  global _TYPE_TO_ENCODER
  global _TYPE_NAME_TO_DECODER
  if object_type not in _TYPE_TO_ENCODER:
    _TYPE_TO_ENCODER[object_type] = encoder
    _TYPE_NAME_TO_DECODER[object_type.__name__] = decoder