Swiftpack.co - Package - raymccrae/swift-jsonpatch

JSONPatch - Swift 4/5 json-patch implementation

Apache 2 License Supported Platforms Build System

JSONPatch is a a swift module implements json-patch RFC6902. JSONPatch uses JSONSerialization from Foundation, and has no dependencies on third-party libraries.

The implementation uses the JSON Patch Tests project for unit tests to validate its correctness.


1.0.2 - Support Swift 5



See CocoaPods.md

Swift Package Manager

See SPM.md


See Carthage.md


A more detailed explanation of JSONPatch is given in Usage.md.

Applying Patches

import JSONPatch

let sourceData = Data("""
                      {"foo": "bar"}
let patchData = Data("""
                     [{"op": "add", "path": "/baz", "value": "qux"}]

let patch = try! JSONPatch(data: patchData)
let patched = try! patch.apply(to: sourceData)

Generating Patches

import JSONPatch

let sourceData = Data("""
                      {"foo": "bar"}
let targetData = Data("""
                      {"foo": "bar", "baz": "qux"}
let patch = try! JSONPatch(source: sourceData, target: targetData)
let patchData = try! patch.data()


Apache License v2.0


Stars: 4
Help us keep the lights on


Used By

Total: 0


1.0.2 - Oct 7, 2019

  • A small release to fix the deprecate warning for Swift 5.
  • Documentation updated with steps to use SPM integration within Xcode 11.

v1.0.1 - Aug 26, 2019

Added support for Carthage.

Thanks to Cassiano Monteiro (cassianodialpad) for his contribution.

v1.0 - Jan 4, 2019

The first fully feature complete release.

v0.2 - Dec 2, 2018

v0.1 - Nov 17, 2018

  • New Project
  • json-patch implementation in Swift 4 to apply patches
  • 100% passes JSON Patch Tests