Repository navigation
Add JSONPatch.difference producing RFC 6902 operations - #96
Merged
Merged
Conversation
JSONPatch.difference(from:to:options:) and differenceWithReport compute a deterministic structural patch that turns one exact value into another. Equal values produce no operation; objects diff by exact key, arrays keep their equal prefix and suffix and compare the remaining elements by position, and other changes are replaced. No move, copy or test is generated, and the result is not minimal. Both inputs, every comparison, Pointer and produced operation share one cumulative patch ledger with cancellation checks. Tests cover expected operations, Pointer escaping, scalar-distinct keys, root replacement, a 600-pair generated corpus where applying the patch yields the target, limits, reports and cancellation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
1.10 exact interchange, part 2:
JSONPatch.difference(from:to:options:)anddifferenceWithReportcompute a structural RFC 6902 patch that turnssourceintotarget.1.0/1), decoded scalars and order-independent objects produce no operation.move,copyortest.JSONWorkMeter(domain.patch), with.operationsand.pointerTokenslimits and cancellation checks in loops.Docs:
Patch.md"Structural difference", DocC topics inJSONPatch.md, CHANGELOG under 1.10.0 (in progress). CLI identity regenerated. JSONPatchTests 16 → 22 inTestDiscovery.json.Qualification (local)
Toolchain: Apple Swift 6.4.2 (swiftlang-6.4.2.1.9), macOS 27.3. Source:
24f6adaonb9040c2.python3 Scripts/ci.py --lane docs: exit 0, 4/4 commands passedpython3 Scripts/ci.py --lane native: exit 0, 62/62 commands passed, 0 failedTests include a 600-pair deterministic generated corpus where every patch applies to the source and yields the target.
No tag, release or publication follows from this PR.
🤖 Generated with Claude Code