• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nlohmann / json / 43176979815
100%

Build:
DEFAULT BRANCH: develop
Ran 12 Nov 2026 11:48AM UTC
Jobs 1
Files 62
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 Nov 2026 07:40AM UTC coverage: 99.692% (-0.01%) from 99.702%
43176979815

push

github

web-flow
Read a std::u8string from a JSON string and store it as one in every configuration (#6075)

* Read a std::u8string from a JSON string and store it as one in every configuration

In C++20, json(std::u8string) was stored as a JSON string only when
std::filesystem::path support was available (the to_json overload sat
inside the JSON_HAS_FILESYSTEM guard), and there was no matching
from_json, so get<std::u8string>() threw type_error.302 ("type must be
array, but is string"). Without std::filesystem, the same expression
still produced an array of code units (the 3.12.0 behavior).

Move the to_json overload out of the filesystem guard so that a
std::u8string is a string in every configuration, build the value
directly from the code units (this also works for a custom string_t
such as the tests' alt_string), and add a from_json overload that reads
a JSON string. The array of numbers written by 3.12.0 is still accepted;
other types throw type_error.302 ("type must be string or array").
std::u8string_view and char8_t arrays are unchanged.

The tests now run in C++20/23 (the file mentions JSON_HAS_CPP_20/23),
also without std::filesystem (test-conversions2_no_filesystem), and with
ordered_json and a custom string type. The new behavior is documented.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* Fill the std::u8string with resize and indexing instead of push_back

The push_back loop is not vectorized: reading a 1 kB string took about
2.2 us against 0.39 us with resize and direct element access (clang -O2).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* Write the std::u8string from_json template header in the compact form

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* Ignore libstdc++ char to char8_t sign change in the clang sanitizer job

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

37681 of 126608 branches covered (29.76%)

16 of 16 new or added lines in 2 files covered. (100.0%)

3 existing lines in 2 files now uncovered.

17145 of 17198 relevant lines covered (99.69%)

5000171.48 hits per line

Coverage Regressions

Lines Coverage ∆ File
2
99.83
-0.11% include/nlohmann/detail/input/binary_reader.hpp
1
99.96
0.0% include/nlohmann/json.hpp
Jobs
ID Job ID Ran Files Coverage
1 43176979815.1 12 Nov 2026 11:48AM UTC 62
99.69
GitHub Action Run
Source Files on build 43176979815
  • Tree
  • List 62
  • Changed 12
  • Source Changed 10
  • Coverage Changed 12
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #43176979815
  • cdfb130f on github
  • Prev Build on develop (#42986024726)
  • Next Build on develop (#43378751572)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc