Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

dewango/JSONPatchSwift

Open more actions menu

Repository files navigation

JSON Patch (RFC 6902) in Swift Build Status Coverage Status

JSONPatchSwift is an implementation of JSONPatch (RFC 6902) in pure Swift. It uses SwiftyJSON for JSON handling.

Installation

CocoaPods (iOS 9.0+, OS X 10.10+)

You can use CocoaPods to install JSONPatchSwiftby adding it to your Podfile:

platform :ios, '9.0'
use_frameworks!

target 'MyApp' do
	pod 'JSONPatchSwift', :git => 'https://github.com/EXXETA/JSONPatchSwift.git'
end

Note that this requires CocoaPods version 36, and your iOS deployment target to be at least 9.0:

Usage

Initialization

import JSONPatchSwift

Using a String:

let jsonPatch = try? JPSJsonPatch("{ \"op\": \"add\", \"path\": \"/baz\", \"value\": \"qux\" }")

Or using a SwiftyJSON object:

let json = JSON(data: " { \"op\": \"add\", \"path\": \"/baz\", \"value\": \"qux\" } ".dataUsingEncoding(NSUTF8StringEncoding)!)
let jsonPatch = try? JPSJsonPatch(json)

Apply it on a JSON

let json = JSON(data: " { \"foo\" : \"bar\" } ".dataUsingEncoding(NSUTF8StringEncoding)!)
let resultingJson = try? JPSJsonPatcher.applyPatch(jsonPatch, toJson: json)

Supported Operations

The framework supports all operations described by RFC 6902. Until we (or you? - see "contributing") find the time to add a documentation for each operation, we kindly ask to use our extensive test suite to find examples:

Requirements

  • iOS 9.0+
  • Xcode 7

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

History

  • v1.2 - upgrade to 100% documented and 100% tested
  • v1.1 - fixed a packaging problem
  • v1.0 - initial release

Credits

License

Apache License v2.0

About

JSON Patch (RFC 6902) in Swift

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.