def to_json(self):
    """Serialize KeyRange to json.

    Returns:
      string with KeyRange json representation.
    """
    if simplejson is None:
      raise SimplejsonUnavailableError(
          "JSON functionality requires simplejson to be available")

    def key_to_str(key):
      if key:
        return str(key)
      else:
        return None

    obj_dict = {
        "direction": self.direction,
        "key_start": key_to_str(self.key_start),
        "key_end": key_to_str(self.key_end),
        "include_start": self.include_start,
        "include_end": self.include_end,
        }
    if self._app:
      obj_dict["_app"] = self._app

    return simplejson.dumps(obj_dict, sort_keys=True)
Serialize KeyRange to json.

    Returns:
      string with KeyRange json representation.
    
mapreduce/lib/key_range/__init__.py