Skip to content

RFC 7386 JSON Merge Patch serialization with compact format#885

Open
rickwierenga wants to merge 4 commits intomainfrom
json-merge
Open

RFC 7386 JSON Merge Patch serialization with compact format#885
rickwierenga wants to merge 4 commits intomainfrom
json-merge

Conversation

@rickwierenga
Copy link
Member

Summary

  • Add apply_merge_patch(), create_merge_patch(), and compact() to serializer.py implementing RFC 7386 JSON Merge Patch
  • compact() strips fields matching constructor defaults from serialized resource trees, producing smaller JSON
  • Resource.save() now emits compact format automatically
  • All deserialize() methods (12 files) updated to tolerate missing optional fields, so both old full-format and new compact-format JSON load correctly
  • deserialize() in the core serializer now fills missing params from __init__ defaults before calling constructors

Test plan

  • 34 new/updated tests in serializer_tests.py covering apply_merge_patch, create_merge_patch, compact, and round-trip deserialization
  • All 563 existing tests pass unchanged
  • Verified old full-format JSON still deserializes correctly (backward compat)
  • Verified compact JSON with missing optional fields deserializes correctly
  • Verified Resource.save()Resource.load_from_json_file() round-trip

🤖 Generated with Claude Code

Add apply_merge_patch(), create_merge_patch(), and compact() to the
serializer. compact() strips fields matching constructor defaults from
serialized resource trees, producing smaller JSON without losing
information. Resource.save() now emits compact format. All deserialize()
methods tolerate missing optional fields so both old full-format and new
compact-format JSON load correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rickwierenga
Copy link
Member Author

as suggested by @Koeng101 in https://discuss.pylabrobot.org/t/json-merge-vs-json-patch/442

rickwierenga and others added 3 commits February 12, 2026 22:06
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove deserialize methods that just mirror the constructor signature
(Rotation, PlateAdapter, Serial, Socket, HamiltonTip, Barcode,
CytomatRack, HeraeusCytomatBackend, SCILABackend, PumpCalibration).
The generic deserializer or MachineBackend.deserialize handles these.

Use deserialize() instead of Rotation.deserialize() in remaining
methods. Fix MachineBackend.deserialize referencing data["type"] after
popping it.

Co-Authored-By: Claude Opus 4.6 <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.

1 participant