Skip to content

jasnell/json-tools

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 

JSON Tools

A basic implementation of the JSON Patch, Pointer and Predicate specifications.

gem install json-tools
require 'jsontools'
include JsonTools

my_hash = JSON.parse %Q/
  {
    "a": {
      "b": {
        "c": "123!ABC"
      }
    }
  }
/

my_patch = JSON.parse %Q!
  [
    {
      "op": "contains",
      "path": "/a/b/c",
      "value": "ABC"
    },
    {
      "op": "replace",
      "path": "/a/b/c",
      "value": 123
    }
  ]
!

patch = Patch.new_with_predicates my_patch

# create new modified hash
new_hash = patch.apply_to my_hash

# edit hash in place
patch.apply_to! my_hash

Additional details to come later.

About

JSON Patch, Pointer and Predicate implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages