# Buggy code
def _upload_package(
    self,
    pref,
    retry=None,
    retry_wait=None,
    integrity_check=False,
    policy=None,
    p_remote=None,
):
    assert pref.revision is not None, "Cannot upload a package without PREV"
    assert pref.ref.revision is not None, "Cannot upload a package without RREV"

    conanfile_path = self._cache.package_layout(pref.ref).conanfile()
    self._hook_manager.execute(
        "pre_upload_package",
        conanfile_path=conanfile_path,
        reference=pref.ref,
        package_id=pref.id,
        remote=p_remote,
    )

    t1 = time.time()
    the_files = self._compress_package_files(pref, integrity_check)

    with self._cache.package_layout(pref.ref).update_metadata() as metadata:
        metadata.packages[pref.id].checksums = calc_files_checksum(the_files)

    if policy == UPLOAD_POLICY_SKIP:
        return None
    files_to_upload, deleted = self._package_files_to_upload(
        pref, policy, the_files, p_remote
    )

    if files_to_upload or deleted:
        self._remote_manager.upload_package(
            pref, files_to_upload, deleted, p_remote, retry, retry_wait
        )
        logger.debug("UPLOAD: Time upload package: %f" % (time.time() - t1))
    else:
        self._output.info("Package is up to date, upload skipped")

    duration = time.time() - t1
    log_package_upload(pref, duration, the_files, p_remote)
    self._hook_manager.execute(
        "post_upload_package",
        conanfile_path=conanfile_path,
        reference=pref.ref,
        package_id=pref.id,
        remote=p_remote,
    )

    logger.debug("UPLOAD: Time uploader upload_package: %f" % (time.time() - t1))

    metadata = self._cache.package_layout(pref.ref).load_metadata()
    cur_package_remote = metadata.packages[pref.id].remote
    if not cur_package_remote and policy != UPLOAD_POLICY_SKIP:
        with self._cache.package_layout(pref.ref).update_metadata() as metadata:
            metadata.packages[pref.id].remote = p_remote.name

    return pref


# Traceback (json.decoder.JSONDecodeError)
[b] $ cmd.exe /C "conan upload "*" --confirm --all --no-overwrite --parallel &amp;&amp; exit %%ERRORLEVEL%%"
ERROR: Extra data: line 1 column 4508 (char 4507)
Traceback (most recent call last):
File "e:\j\e1\b\venv\lib\site-packages\conans\client\command.py", line 1969, in run
method(args[0][1:])
File "e:\j\e1\b\venv\lib\site-packages\conans\client\command.py", line 1410, in upload
parallel_upload=args.parallel)
File "e:\j\e1\b\venv\lib\site-packages\conans\client\conan_api.py", line 81, in wrapper
return f(api, *args, **kwargs)
File "e:\j\e1\b\venv\lib\site-packages\conans\client\conan_api.py", line 887, in upload
parallel_upload=parallel_upload)
File "e:\j\e1\b\venv\lib\site-packages\conans\client\cmd\uploader.py", line 87, in upload
query, package_id)
File "e:\j\e1\b\venv\lib\site-packages\conans\client\cmd\uploader.py", line 145, in _collect_packages_to_upload
metadata = self._cache.package_layout(ref).load_metadata()
File "e:\j\e1\b\venv\lib\site-packages\conans\paths\package_layouts\package_cache_layout.py", line 171, in load_metadata
return PackageMetadata.loads(text)
File "e:\j\e1\b\venv\lib\site-packages\conans\model\package_metadata.py", line 95, in loads
data = json.loads(content)
File "C:\Program Files\Python37\Lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Program Files\Python37\Lib\json\decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 4508 (char 4507)

Conan build failed

# Fixed code
def _upload_package(
    self,
    pref,
    retry=None,
    retry_wait=None,
    integrity_check=False,
    policy=None,
    p_remote=None,
):
    assert pref.revision is not None, "Cannot upload a package without PREV"
    assert pref.ref.revision is not None, "Cannot upload a package without RREV"

    pkg_layout = self._cache.package_layout(pref.ref)
    conanfile_path = pkg_layout.conanfile()
    self._hook_manager.execute(
        "pre_upload_package",
        conanfile_path=conanfile_path,
        reference=pref.ref,
        package_id=pref.id,
        remote=p_remote,
    )

    t1 = time.time()
    the_files = self._compress_package_files(pref, integrity_check)

    if policy == UPLOAD_POLICY_SKIP:
        return None
    files_to_upload, deleted = self._package_files_to_upload(
        pref, policy, the_files, p_remote
    )

    if files_to_upload or deleted:
        self._remote_manager.upload_package(
            pref, files_to_upload, deleted, p_remote, retry, retry_wait
        )
        logger.debug("UPLOAD: Time upload package: %f" % (time.time() - t1))
    else:
        self._output.info("Package is up to date, upload skipped")

    duration = time.time() - t1
    log_package_upload(pref, duration, the_files, p_remote)
    self._hook_manager.execute(
        "post_upload_package",
        conanfile_path=conanfile_path,
        reference=pref.ref,
        package_id=pref.id,
        remote=p_remote,
    )

    logger.debug("UPLOAD: Time uploader upload_package: %f" % (time.time() - t1))

    # Update the package metadata
    checksums = calc_files_checksum(the_files)
    with pkg_layout.update_metadata() as metadata:
        cur_package_remote = metadata.packages[pref.id].remote
        if not cur_package_remote:
            metadata.packages[pref.id].remote = p_remote.name
        metadata.packages[pref.id].checksums = checksums

    return pref