Skip to content

icholy/JsonPatch.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsonPatch with Slices (this is an experiment) Build Status

This is loosely based on the json-patch draft.

The project was motivated by an earlier rant

Original Data

var JsonPatch = require('jsonpatch'),
    patcher = new JsonPatch();

var someData = {
	foo: [
		{ x: 1 },
		{ y: 2 }
	]
};

Remove slice

patcher.apply(someData, [{ op: 'remove', path: '/foo/0:2'}] );

// resulting object
{
  foo: [],
}

Move slice contents

patcher.apply(someData, [{ op: 'move', path: '/foo/0:2/x', to: '/bar' }] );

// resulting object
{
  foo: [
    {},
    {}
  ],
  bar: [1, 2]
}

Slices can be used with the other operations too:

  • add
  • remove
  • replace
  • move
  • copy

See more examples in the tests

About

experimenting with slices in Json pointers and patches

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published