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

nlohmann / json / 36018417097
98%

Build:
DEFAULT BRANCH: develop
Ran 24 Sep 2026 10:15PM UTC
Jobs 1
Files 34
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

24 Sep 2026 03:12PM UTC coverage: 97.697% (-0.2%) from 97.863%
36018417097

push

github

web-flow
Merge deeply nested objects without recursing per nesting level (#5547)

* Merge deeply nested objects without recursing per nesting level

merge_patch() and update(j, true) merged a nested object by calling
themselves on it, once per nesting level. A value nested deeply enough -
50,000 levels of objects on an 8 MiB stack - exhausted the call stack
and terminated the process, although parse() accepts such values without
complaint.

Bound the descent the same way dump() does. The recursion now carries
the nesting level, and once merge_depth_limit() (128) levels have been
entered, update_members_iteratively() and merge_patch_iteratively()
finish the merge on an explicit stack. They still merge a nested object
completely before the next member, and in the same order, so the results,
including the parents JSON_DIAGNOSTICS reports paths from, are unchanged.
Values nested less deeply than the bound run the same code as before, so
the common case does not pay for the stack: merging only on it cost
10-14% in a first version.

The public signatures are unchanged. The recursive worker behind
merge_patch() has its own name rather than being a private overload, so
that &basic_json::merge_patch stays unambiguous.

Tests check every depth up to 300 against recursive reference
implementations of both operations, check the diagnostic paths past the
bound, and merge objects nested 100,000 levels deep.

Fixes #5545 for update(j, true), and #5393 for merge_patch().

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

* Use the shared recursion limit in update() and merge_patch()

merge_depth_limit() is gone in favor of detail::recursion_depth_limit().
The two identical function-local frame structs become one member struct,
merge_frame, with a constructor, so both loops emplace_back() their
frames. merge_patch_iteratively() copies the frame it works on out of the
stack and changes it only through stack.back().

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

* Build the up... (continued)

2769 of 3011 branches covered (91.96%)

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

103 existing lines in 3 files now uncovered.

7677 of 7858 relevant lines covered (97.7%)

16929851.8 hits per line

Coverage Regressions

Lines Coverage ∆ File
60
96.58
-0.73% include/nlohmann/json.hpp
40
90.29
-0.03% include/nlohmann/detail/output/serializer.hpp
3
99.66
0.0% include/nlohmann/detail/output/binary_writer.hpp
Jobs
ID Job ID Ran Files Coverage
1 36018417097.1 24 Sep 2026 10:15PM UTC 34
97.7
GitHub Action Run
Source Files on build 36018417097
  • Tree
  • List 34
  • Changed 6
  • Source Changed 6
  • Coverage Changed 6
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #36018417097
  • 4daca40d on github
  • Prev Build on develop (#35957700508)
  • Next Build on develop (#36104393114)
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