Skip to content

COMP: Update jsonxx to latest TransitApp/jsonxx#98

Open
thewtex wants to merge 3 commits intoInsightSoftwareConsortium:masterfrom
thewtex:ci-updates
Open

COMP: Update jsonxx to latest TransitApp/jsonxx#98
thewtex wants to merge 3 commits intoInsightSoftwareConsortium:masterfrom
thewtex:ci-updates

Conversation

@thewtex
Copy link
Copy Markdown
Member

@thewtex thewtex commented May 29, 2024

Update vendored jsonxx from hjiang/jsonxx v1.0.1 (2021) to TransitApp/jsonxx master (eede690, 2025-11-24). TransitApp's fork is the actively maintained continuation with includes cleanup and bug fixes.

Changes
  • jsonxx.h / jsonxx.cc: Updated to latest TransitApp/jsonxx (eede690). Includes cleanup: cassert moved out of header, string_view support added, general code improvements.
  • MSVC fix: Replaced GCC case range extension ('0'...'9') with individual case labels for MSVC compatibility.
  • clang-format: Applied project clang-format 19.1.7 to vendored files.
  • Rebased onto current master (v5.4.6 CI, blowekamp's iterator benchmarks, CMake fixes from ENH: Replace --no-merges with --first-parent for comment #76).
Previous review comments
  • jhlegarreta's comment about removing 14 from CMake standard comment — already addressed on master via earlier PRs.

Copy link
Copy Markdown
Member

@jhlegarreta jhlegarreta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this Matt.

Comment thread CMakeLists.txt Outdated
@thewtex
Copy link
Copy Markdown
Member Author

thewtex commented May 31, 2024

I think we need to move to a different JSON library -- the existing one fails to build with MSVC and is not maintained.

@phcerdan
Copy link
Copy Markdown
Contributor

I think we need to move to a different JSON library -- the existing one fails to build with MSVC and is not maintained.

This one is really famous: https://github.com/nlohmann/json, it seems great to use, but slow performance (not sure about our requirements).

The fastest is simdjson: https://github.com/simdjson/simdjson/#performance-results

@thewtex
Copy link
Copy Markdown
Member Author

thewtex commented Jun 3, 2024

:Ooo:, simdjson looks nice!

I am also finding glaze:

https://github.com/stephenberry/glaze

Claims to be faster than simdjson, but requires C++20. Has a neat reflection API.

Update vendored jsonxx to TransitApp/jsonxx master (eede690, 2025-11-24)
which includes an includes cleanup removing cassert from the header.
The original hjiang/jsonxx repo (v1.0.1) has not been updated since 2021;
TransitApp fork is the actively maintained continuation.

Replace GCC case range extension with individual case labels for MSVC.

Applied clang-format 19.1.7 to match project style.
@hjmjohnson hjmjohnson changed the title ENH: Update GitHub Actions configuration for ITK 5.4.0 COMP: Update jsonxx to latest TransitApp/jsonxx Apr 14, 2026
Replace `static const Object EmptyObject = {};` (and Array, Value
variants) with `inline` accessor functions returning a local static.
The `static const` form creates per-TU copies whose constructors
reference symbols defined in jsonxx.cc — when the header test TU
links against the shared library on Windows, MSVC cannot resolve
these symbols because they lack __declspec(dllexport).

The `inline` function with a local static is C++17-safe, ODR-correct,
and avoids the linker dependency entirely.
@hjmjohnson
Copy link
Copy Markdown
Member

Pushed fix for MSVC linker errors (LNK2019: unresolved external symbol for Object::Object, Array::Array, Value::Value constructors/destructors).

Root cause

TransitApp/jsonxx declares static const Object EmptyObject = {}; (and Array/Value variants) in the header. Each TU that includes the header creates its own copy, calling constructors defined in jsonxx.cc. On Windows with shared libraries, these constructors aren't __declspec(dllexport)-ed from the DLL, so the header test TU gets LNK2019.

Fix: replaced with inline accessor functions returning a local static — C++17-safe, ODR-correct, no cross-TU linker dependency.

@hjmjohnson
Copy link
Copy Markdown
Member

Windows CI still failing — but this is now an upstream action bug, not a jsonxx issue.

The v5.4.6 branch of ITKRemoteModuleBuildTestPackageAction received the Windows path-shortening fix (#128 → #129), but that fix introduced a shell compatibility bug: the "Download ITK" step uses $ITK_BUILD_ROOT (bash syntax) without shell: bash, so on Windows (where GitHub Actions defaults to pwsh) the variable is undefined and ITK gets cloned to the wrong location.

Fix PRs: ITKRemoteModuleBuildTestPackageAction#130 (v5.4.6) and #131 (main). Once merged, CI here should be re-triggered.

Error trace
CMake Error: The source directory "D:/PerformanceB/ITK" does not exist.
ninja: error: loading 'build.ninja': The system cannot find the file specified.

The junction D:\PerformanceBD:\a\ITKPerformanceBenchmarking is created correctly, but the Download ITK step's cd "$ITK_BUILD_ROOT" is a no-op in PowerShell (needs $env:ITK_BUILD_ROOT). ITK gets cloned inside the repo checkout dir instead of at the junction root.

Copy link
Copy Markdown
Member

@hjmjohnson hjmjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating to the new vendored code seems to work accross the platforms.

Copy link
Copy Markdown
Member Author

@thewtex thewtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants