'Serialize KeyRange to json.
Returns:
string with KeyRange json representation.'

def to_json(self):

    if (simplejson is None):
        raise SimplejsonUnavailableError('JSON    functionality    requires    json    or    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, 'namespace': self.namespace}
    if self._app:
        obj_dict['_app'] = self._app
    return simplejson.dumps(obj_dict, sort_keys=True)
