Latest 1.0
Homepage https://github.com/raymccrae/swift-jsonpatch
License Apache License, Version 2.0
Platforms ios 8.0, osx 10.10
Authors

JSONPatch – Swift 4 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 – Feature complete.

Installation

CocoaPods

To use JSONPatch within your project. Add the "RMJSONPatch" into your Podfile:

platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'RMJSONPatch', :git => 'https://github.com/raymccrae/swift-jsonpatch.git'
end

Swift Package Manager

Add JSONPatch as a dependency to your projects Package.swift. For example: –

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "YourProject",
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://github.com/raymccrae/swift-jsonpatch.git", .branch("master"))
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "YourProject",
            dependencies: ["JSONPatch"]),
    ]
)

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

Latest podspec

{
    "name": "RMJSONPatch",
    "version": "1.0",
    "summary": "JSONPatch is a swift library for applying and generating RFC-6902 compliant JSON patches.",
    "module_name": "JSONPatch",
    "description": "JSONPatch is a swift library for applying and generating RFC-6902 compliant JSON patches.nThe library is built on top of JSONSerialization from Foundation and offers many conveniencenmethods to make it easy to work with json-patches.",
    "homepage": "https://github.com/raymccrae/swift-jsonpatch",
    "license": {
        "type": "Apache License, Version 2.0",
        "file": "LICENSE"
    },
    "authors": {
        "Raymond McCrae": "[email protected]"
    },
    "social_media_url": "http://twitter.com/raymccrae",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10"
    },
    "source": {
        "git": "https://github.com/raymccrae/swift-jsonpatch.git",
        "tag": "v1.0"
    },
    "source_files": [
        "JSONPatch",
        "Sources/**/*.{h,swift}"
    ],
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This