Skip to content

The jsonpatch command applies RFC 6902 JSON Patches to JSON or YAML documents.

Notifications You must be signed in to change notification settings

nicksnyder/jsonpatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonpatch

The jsonpatch command applies RFC 6902 JSON Patches to JSON or YAML documents.

Install

Install the latest with go get -u github.com/nicksnyder/jsonpatch.

Example

document1.json

{
  "a": 1
}

document2.json

{
  "b": 2
}

patch.json

[{ "op": "add", "path": "/c", "value": 3 }]

Running jsonpatch

$ jsonpatch patch.json document1.json document2.json
$ cat document1.json
{
  "a": 1,
  "c": 3
}
$ cat document2.json
{
  "b": 2,
  "c": 3
}

Batch example

document1.json

{
  "a": 1
}

document2.json

{
  "b": 2
}

batch.json

[
  {
    "glob": "document1*",
    "jsonPatch": [{ "op": "add", "path": "/c", "value": 3 }]
  },
  {
    "glob": "document2*",
    "jsonPatch": [{ "op": "add", "path": "/d", "value": 4 }]
  }
]

Running jsonpatch

$ jsonpatch batch.json
$ cat document1.json
{
  "a": 1,
  "c": 3
}
$ cat document2.json
{
  "b": 2,
  "c": 4
}

About

The jsonpatch command applies RFC 6902 JSON Patches to JSON or YAML documents.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published