Repository navigation
Conversation
nlohmann
added this pull request to stack #5636
September 29, 2026 14:20
nlohmann
removed this pull request from stack #5636
September 30, 2026 13:19
nlohmann
force-pushed
the
json-view/19-edit-set
branch
from
September 30, 2026 13:20
711ddc4 to
c675bcd
Compare
nlohmann
force-pushed
the
json-view/20-edit-structure
branch
from
September 30, 2026 13:20
0e14d93 to
274be40
Compare
nlohmann
added this pull request to stack #5739
September 30, 2026 13:21
nlohmann
force-pushed
the
json-view/19-edit-set
branch
from
September 30, 2026 15:34
c675bcd to
ad5feb1
Compare
nlohmann
force-pushed
the
json-view/20-edit-structure
branch
3 times, most recently
from
September 30, 2026 18:06
580f0f9 to
9c0bd2b
Compare
nlohmann
marked this pull request as ready for review
September 30, 2026 18:16
- insert(array, index, value): insert before an element (index <= size) - erase(object, key): remove all members with the key; returns their number - erase(array, index): remove an element - erase(json_pointer): remove the member or element a pointer names The errors are those of basic_json (type_error.307/309, out_of_range.401/403/405). A view of an erased value keeps its last value, and views of other values keep referring to them when elements move. Tests: the differential test now also inserts and erases members and elements, directly and through JSON pointers; plus the errors, views across inserts and erasures, duplicate keys, and large objects. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
bench_edit.cpp joins the comparison: parse, apply the same logical edits with each library's own API (a handful at fixed places, or one in every record), and serialize; all outputs must describe the same value. compare.py builds and runs it with the other two programs. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Add API reference pages for basic_json_document::insert and basic_json_document::erase, matching the style of set.md and push_back.md: signatures, parameters, return values, exception safety, exceptions with their exact ids and messages, complexity, notes on duplicate keys and view/iterator validity, and an example. Add example programs basic_json_document__insert.cpp and basic_json_document__erase.cpp with their expected output, each comparing an edit on an editable document with the same edit on a plain json value to show what is preserved: member order, the spelling of untouched numbers, and, for insert, that a view taken before the insert keeps referring to the same element after its index shifts. Register both new pages in mkdocs.yml, docSet.sql, and the member list of basic_json_document/index.md, add cross-references to them from set.md and push_back.md, and mention insert/erase in the "Editing a document" section of features/json_view.md. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann
force-pushed
the
json-view/19-edit-set
branch
from
September 30, 2026 19:19
d52db33 to
467ccfd
Compare
nlohmann
force-pushed
the
json-view/20-edit-structure
branch
from
September 30, 2026 19:19
9c0bd2b to
a496c70
Compare
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
nlohmann
removed this pull request from stack #5739
October 6, 2026 09:26
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the stack for the zero-copy view (#5295).
Summary
Editable documents can now change the structure of arrays and objects:
insert(array, index, value)inserts before an element (index <= size()) and returns a view of the new element;erase(object, key)removes all members with the key and returns their number;erase(array, index)removes an element;erase(json_pointer)removes the member or element a pointer names and returns the number of removed values.A view of an erased value keeps its last value. Views of other values keep referring to them when elements move.
Errors are those of
basic_json: type_error.307/309 and out_of_range.401/403/405.bench_edit.cppjoins the comparison harness. It parses, applies the same logical edits with each library's own API (a handful at fixed places, or one in every record), and serializes; all outputs must describe the same value.compare.pybuilds and runs it with the other two programs.Benchmarks
bench_editat this PR, on Apple M1, best of 25 rounds. Each run parses, applies the edits, and serializes. json_view's time is the base (1.00×); higher factors are slower:jsonSerializing (
dump()) takes about half of json_view's time on twitter and most of it on canada. It gets faster later in the stack, in the PRs that add the compact writer, Żmij, and floats written from their digits. At the top of the stack (same machine and method,patch):x86-64 numbers are still missing.
Tests
Documentation
insertanderase, with examples.Public API
No breaking change. The new members exist only for editable documents.
Written by Claude Code.
🤖 Generated with Claude Code