Sha256: d0fd3c98f608c73a837a90f7cb24acef3887229bd8551b2a94130571610320f6
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
# Json::MergePatch [![Build Status](https://travis-ci.org/steveklabnik/json-merge_patch.png)](https://travis-ci.org/steveklabnik/json-merge_patch) This gem augments Ruby's built-in JSON library to support merging JSON blobs in accordance with the [draft-snell-merge-patch draft](http://tools.ietf.org/html/draft-snell-merge-patch-08). ## Installation Add this line to your application's Gemfile: gem 'json-merge_patch' And then execute: $ bundle Or install it yourself as: $ gem install json-merge_patch ## Usage First, require the gem: ```ruby require 'json/merge_patch' ``` Then, use it: ```ruby # The example from http://tools.ietf.org/html/draft-snell-merge-patch-08#section-2 document = <<-JSON { "title": "Goodbye!", "author" : { "givenName" : "John", "familyName" : "Doe" }, "tags":["example","sample"], "content": "This will be unchanged" } JSON merge_patch = <<-JSON { "title": "Hello!", "phoneNumber": "+01-123-456-7890", "author": { "familyName": null }, "tags": ["example"] } JSON JSON.merge(document, merge_patch) # => { "title": "Goodbye!", "author" : { "phoneNumber": "+01-123-456-7890", "givenName" : "John", }, "tags":["example"], "content": "This will be unchanged" } ``` ## 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. Create new Pull Request
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
json-merge_patch-0.1.0 | README.md |
json-merge_patch-0.0.1 | README.md |