import json


def ToCanonicalJSON(dict, indent=False):
  """Convert "dict" to a canonical JSON string. Sort keys so that output
  ordering is always the same.
  """
  return json.dumps(dict, sort_keys=True, indent=indent)