Project

json-tools

0.0
No commit activity in last 3 years
No release in over 3 years
A JSON Patch + Pointer + Predicates Implementation
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

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.