<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_json(self, obj, host=None, indent=None):
 """Recursively encode `obj` and convert it to a JSON string. :param obj: Object to encode. :param host: hostname where this object is being encoded. :type host: str"""

        if indent:
            return json.dumps(deep_map(lambda o: self.encode(o, host), obj),
                              indent=indent)
        else:
            return json.dumps(deep_map(lambda o: self.encode(o, host), obj))