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.4 - Fix bug that raised an Objective-C exception when copying a json element with a NSNumber.
See CocoaPods.md
See SPM.md
See Carthage.md
A more detailed explanation of JSONPatch is given in Usage.md.
import JSONPatch
let sourceData = Data("""
{"foo": "bar"}
""".utf8)
let patchData = Data("""
[{"op": "add", "path": "/baz", "value": "qux"}]
""".utf8)
let patch = try! JSONPatch(data: patchData)
let patched = try! patch.apply(to: sourceData)
import JSONPatch
let sourceData = Data("""
{"foo": "bar"}
""".utf8)
let targetData = Data("""
{"foo": "bar", "baz": "qux"}
""".utf8)
let patch = try! JSONPatch(source: sourceData, target: targetData)
let patchData = try! patch.data()
Apache License v2.0