json-patch 0.0.1

RFC 6902 JSON Patch implementation


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Build Status codecov license

JavaScript Object Notation (JSON) Patch

This is implementation of rfc6902.

JSON Patch defines a JSON document structure for expressing a sequence of operations to apply to a JavaScript Object Notation (JSON) document.

library functionality:

  • generate diff between two documents
  • patch in place document using generated patch

Json document format accepted: JSONValue

Interface

	alias JsonItem = JSONValue;
    
	// diff part
	DiffOperation[] diff(const ref JsonItem source, const ref JsonItem target,
                           const string path = "");

	JsonItem toJson(DiffOperation[] d);
	
	// patch part
	
	bool patchInPlace(ref JsonItem document, ref const JsonItem patch);

Usage

	import vision.json.patch.commons;
	import vision.json.patch.diff;
	import vision.json.patch.patch;
    
	JsonItem source = ...;
	JsonItem target = ...;
		
	auto patch = diff(source.document, target.document).toJson;
		
	auto patched = source.document;
	patched.patchInPlace(patch);
		
	assert(patched == target)
    
Authors:
  • Alexey Kulentsov
Dependencies:
json-pointer
Versions:
0.0.1 2018-Jun-02
~master 2018-Jun-02
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 9 downloads total

Score:
0.5
Short URL:
json-patch.dub.pm