def METHOD_NAME(self, obj, path):
    """Encode a dict-like object onto a single line.
    """
    return "{" + ", ".join(f"{json.dumps(key)}: {self.encode(value, path + [key])}" for key, value in sorted(obj.items(), key=self.sort_layout)) + "}"