Summary

Implements JsonPatch type for computing diffs and applying patches to JSON values, as specified in issue #685. This implementation directly mirrors the existing DynamicPatch API, adapted for JSON’s simpler data model.

What’s Included

File Description
Json.scala JSON ADT with DynamicValue interop
JsonPatch.scala Patch operations, diff/apply algorithms
JsonError.scala Error handling
JsonPatchLawsSpec.scala Property-based law tests
JsonPatchSpec.scala Unit tests

Design

Mirrors DynamicPatch with JSON-specific simplifications:

  • NumberDelta(BigDecimal) — single numeric delta type
  • StringEdit — LCS-based string diffing
  • ArrayEdit — LCS-based array diffing
  • ObjectEdit — field-based object diffing
  • JsonPatchMode — Strict/Lenient/Clobber

Verified Laws

All pass property-based tests:

  • L1–L3: Monoid laws
  • L4: Roundtrip diff(a,b)(a) == Right(b)
  • L5: Identity diff(j,j).isEmpty
  • L6: Composition
  • L7: Lenient subsumes Strict

Test Results

✅ 20 property-based tests (JsonPatchLawsSpec) ✅ 56+ unit tests (JsonPatchSpec)


/claim #685

Claim

Total prize pool $2,000
Total paid $0
Status Pending
Submitted January 17, 2026
Last updated January 17, 2026

Contributors

BH

Bhaviikkk

@Bhaviikkk

100%

Sponsors

ZI

ZIO

@ZIO

$1,000
JO

John Oluwafemi

@John6150

$1,000