Skip to content

Add back JSON diffing to postbacks #1996

Open
exyi wants to merge 6 commits intomainfrom
utf8-json-diff
Open

Add back JSON diffing to postbacks #1996
exyi wants to merge 6 commits intomainfrom
utf8-json-diff

Conversation

@exyi
Copy link
Member

@exyi exyi commented Feb 15, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request re-introduces JSON diffing functionality for postback responses to reduce payload sizes. Instead of sending the complete viewModel in postback responses, the server now computes a diff between the viewModel it received from the client and the updated viewModel, then sends only the changes.

Changes:

  • Added JsonDiffWriter - a high-performance UTF-8-based JSON diff computation utility that uses ref structs and stack allocation
  • Modified DefaultViewModelSerializer to compute and send viewModelDiff instead of full viewModel when diff source is available
  • Added comprehensive test coverage with 40+ test cases validating the diff algorithm against the existing JsonUtils.Diff implementation

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
JsonDiffWriter.cs New ref struct implementing high-performance JSON diff computation using UTF-8 reader/writer with lazy evaluation for nested objects
JsonPatchWriter.cs Entirely commented-out code for applying patches (should be removed or moved)
DefaultViewModelSerializer.cs Integrated diff computation into serialization flow, added error handling, refactored to support diff mode
JsonDiffTests.cs Added 40+ test cases validating diff algorithm correctness, removed BOM, added debug console output
DotVVM.Framework.csproj Changed target framework order to prioritize net9.0
dotnet-tools.json Added dotnet-stryker mutation testing tool (unrelated to PR)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +128 to +133
catch (Exception ex)
{
writer.Flush();
var failurePath = SystemTextJsonUtils.GetFailurePath(writerStream.ToSpan());
throw new SerializationException(true, context.ViewModel!.GetType(), string.Join("/", failurePath), ex);
}
Comment on lines +323 to +325
{

}
Comment on lines +322 to +325
if (addedToBuffer)
{

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants