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

nlohmann / json / 34326242659
95%

Build:
DEFAULT BRANCH: develop
Ran 09 Sep 2026 01:02PM UTC
Jobs 1
Files 31
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

09 Sep 2026 07:54AM UTC coverage: 98.727% (+0.008%) from 98.719%
34326242659

push

github

web-flow
Reserve capacity in from_json() object conversion when the target container supports it (#5472)

* Reserve capacity in from_json() object conversion when supported

The object-to-container from_json() overload filled the target
container one element at a time without reserving capacity, even
when the target type supports reserve() (e.g. std::unordered_map)
and the number of elements is already known. This caused unnecessary
rehashing while parsing large objects into such containers.

Add a reserve-detecting overload (from_json_object_impl), mirroring
the priority_tag-based SFINAE technique already used by the array
conversion path (from_json_array_impl), so that reserve(size()) is
called up front when available and the loop falls back unchanged
otherwise (e.g. for std::map).

Fixes #5406

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

* Update doc example outputs for new object-conversion iteration order

Reserving capacity in from_json()'s object-conversion path before
inserting elements changes libstdc++'s std::unordered_map bucket
layout, which changes the iteration order used by
get__ValueType_const.cpp, get_to.cpp and operator__ValueType.cpp to
print the elements of a converted std::unordered_map<std::string,
json>. Verified against a clean develop checkout (built with the
same GCC/libstdc++ used in CI) that the old order was produced
without this PR's change and the new order is produced with it, and
that the three affected examples now match their updated expected
output byte-for-byte.

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

* Factor out a reserve-dispatch helper instead of duplicating the object from_json loop

Addresses review feedback from @gregmarr on PR #5472: the emplace loop no
longer needs to exist twice for the reserve/no-reserve cases. A small
from_json_object_reserve() overload pair (SFINAE-dispatched on whether
reserve() exists, mirroring the priority_tag technique used elsewhere)
either calls reserve() or is a no-op; fr... (continued)

2231 of 2393 branches covered (93.23%)

6 of 6 new or added lines in 1 file covered. (100.0%)

35 existing lines in 3 files now uncovered.

6745 of 6832 relevant lines covered (98.73%)

16834666.52 hits per line

Coverage Regressions

Lines Coverage ∆ File
32
97.84
0.02% include/nlohmann/json.hpp
2
98.84
0.0% include/nlohmann/detail/input/parser.hpp
1
98.69
0.02% include/nlohmann/detail/json_pointer.hpp
Jobs
ID Job ID Ran Files Coverage
1 34326242659.1 09 Sep 2026 01:02PM UTC 31
98.73
GitHub Action Run
Source Files on build 34326242659
  • Tree
  • List 31
  • Changed 9
  • Source Changed 9
  • Coverage Changed 6
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #34326242659
  • b17c272f on github
  • Prev Build on develop (#34156274125)
  • Next Build on develop (#34445253992)
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