<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def json_hash(obj, digest=None, encoder=None):
 """Hashes `obj` by dumping to JSON. :param obj: An object that can be rendered to json using the given `encoder`. :param digest: An optional `hashlib` compatible message digest. Defaults to `hashlib.sha1`. :param encoder: An optional custom json encoder. :type encoder: :class:`json.JSONEncoder` :returns: A hash of the given `obj` according to the given `encoder`. :rtype: str :API: public """

  json_str = json.dumps(obj, ensure_ascii=True, allow_nan=False, sort_keys=True, cls=encoder)
  return hash_all(json_str, digest=digest)