Skip to content

refactor(json): migrate serialization from Newtonsoft to System.Text.Json (#349)#351

Open
wrigjl wants to merge 1 commit into
ReduxISU:CSharpAPIfrom
wrigjl:migrate-system-text-json
Open

refactor(json): migrate serialization from Newtonsoft to System.Text.Json (#349)#351
wrigjl wants to merge 1 commit into
ReduxISU:CSharpAPIfrom
wrigjl:migrate-system-text-json

Conversation

@wrigjl

@wrigjl wrigjl commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #349.

Summary

Removes the last uses of Newtonsoft.Json from the API so all JSON serialization goes through System.Text.Json.

The only remaining Newtonsoft consumers were the info and problemInstance endpoints in ProblemProvider.cs. The API_JSON_Converter referenced in the issue was already a System.Text.Json converter and needed no changes.

Changes

  • Replace JsonConvert.SerializeObject(...) with JsonSerializer.Serialize(...) in the info and problemInstance endpoints, passing the runtime type explicitly so STJ emits the concrete object's members instead of an empty {} for the object/IProblem declared type.
  • Enable IncludeFields = true for those endpoints to reproduce Newtonsoft's default of serializing public fields (e.g. ARCSET.K, UtilCollectionGraph.Nodes/Edges).
  • Drop the Newtonsoft.Json package references from API.csproj and redux-tests.csproj.
  • Remove an unused Newtonsoft.Json.Linq import from the MST tests.

Validation

  • Captured info and problemInstance output for CLIQUE, ARCSET, HITTINGSET, SAT3, plus a verifier, solver, and visualization, before and after the change. An order-independent structural JSON diff shows identical output — no client contract change.
  • dotnet build: clean (0 warnings).
  • dotnet test: 678 passed, 0 failed.

🤖 Generated with Claude Code

…Json (ReduxISU#349)

The info and problemInstance endpoints were the last Newtonsoft.Json
users. Replace JsonConvert.SerializeObject with JsonSerializer.Serialize,
passing the runtime type explicitly so System.Text.Json emits the
concrete object's members rather than an empty {} for the object/IProblem
declared type. Enable IncludeFields to reproduce Newtonsoft's default of
serializing public fields (e.g. ARCSET.K, UtilCollectionGraph.Nodes/Edges);
verified endpoint output is structurally identical to the prior behavior.

Drop the Newtonsoft.Json package references from API and redux-tests, and
remove an unused Newtonsoft.Json.Linq import from the MST tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Migrate JSON serialization from Newtonsoft -> System.Text.Json

1 participant