def handler(func):
    """
    Use this decorator to mark a method on a class as being its jsonweb
    encode handler. It will be called any time your class is serialized to a
    JSON string. ::

        >>> from jsonweb import encode           
        >>> @encode.to_object()
        ... class Person(object):
        ...     def __init__(self, first_name, last_name):
        ...         self.first_name = first_name
        ...         self.last_name = last_name
        ...     @encode.handler
        ...     def to_obj(self):
        ...         return {"FirstName": person.first_name, 
        ...             "LastName": person.last_name}
        ...
        >>> @encode.to_list()
        ... class People(object):
        ...     def __init__(self, *persons):
        ...         self.persons = persons        
        ...     @encode.handler
        ...     def to_list(self):
        ...         return self.persons
        ...
        >>> people = People(
        ...     Person("Luke", "Skywalker"),
        ...     Person("Darth", "Vader"),
        ...     Person("Obi-Wan" "Kenobi")
        ... )
        ...
        >>> print dumper(people, indent=2)
        [
          {
            "FirstName": "Luke", 
            "LastName": "Skywalker"
          }, 
          {
            "FirstName": "Darth", 
            "LastName": "Vader"
          }, 
          {
            "FirstName": "Obi-Wan", 
            "LastName": "Kenobi"
          }
        ]

    """
    func._jsonweb_encode_handler = True
    return func
