JSONPatch

1.0.6

JSON Patch RFC6902 implementation in Swift
raymccrae/swift-jsonpatch

What's New

Linux Support

2024-02-01T19:11:31Z
  • Update to support the Linux platform.

Thanks goes to @chrisschlitt for reporting and helping fix and test the changes for Linux.

What's Changed

New Contributors

Full Changelog: 1.0.5...v1.0.6

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.

Release

1.0.6 - Added support for Linux.

Installation

CocoaPods

See CocoaPods.md

Swift Package Manager

See SPM.md

Carthage

See Carthage.md

Usage

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

Applying Patches

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)

Generating Patches

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()

License

Apache License v2.0

Description

  • Swift Tools 4.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Tue Apr 02 2024 23:29:19 GMT-0900 (Hawaii-Aleutian Daylight Time)