TerminusDB Logo all white svg
Search
Close this search box.
Search
Close this search box.
JSON diff and patch

JSON Diff & Patch

An open-source semantic JSON Diff & Patch tool to compare JSON documents to show diffs and apply patches using a free public API

JSON Diff & Patch

When objects change in a distributed system, it’s useful to be able to compare versions to see what has changed.

This is where JSON diff and patch come in. Diff takes two JSON objects and constructs a difference between them so the second object can be obtained from the first by means of a patch operation.

The diff between two documents is particularly useful to see a synopsis of differences in large objects, for instance, technical documentation or system performance analysis. 

JSON Diff and Patch works with TerminusDB, MongoDB, and other document databases. Give the open API a go by visiting our documentation.

				
					# Using TerminusDB Open API for JSON Diff and Patch
tdb_diff = WOQLClient("https://cloud.terminusdb.com/jsondiff")
tdb_patch = WOQLClient("https://cloud.terminusdb.com/jsonpatch")

### Comparing a document object ###
class Person(DocumentTemplate):
    name: str
    age: int

jane = Person(name="Jane", age=18)
janine = Person(name="Janine", age=18)

result_patch = tdb_diff.diff(jane, janine)

pprint(result_patch.content)

# apply result patch to get back final document
after_patch = tdb_patch.patch(jane, result_patch)

pprint(after_patch)
assert after_patch == janine._obj_to_dict()
				
			

Build sense into your build

Developing a feature or new application with a team and need to compare JSON objects? Perhaps you need to validate data to understand the functional performance of your build. The TerminusDB JSON Diff & Patch Module enables you to perform schematically informed diff and patch operations directly with your backend.

Give users the power

Build user-interface-assisted JSON diff and patch functionality into your applications and give users the power to work as a team and keep their data accurate. Applications like CMS, technical documentation, and collaborative knowledge bases benefit from the ability to add approval workflows to deliver data consistency to applications reliant on the quality of their data. 

Approval checks

Where data is surfaced, be it for reporting, financial plans, product listings, or content management, having appropriate approval checks to ensure accuracy and data integrity is crucial. The TerminusDB JSON Diff & Patch Module enables you to add approval checks to data updates, so new product data on an e-commerce platform is correct, the latest report features the right number, or the case study features the right customer quote.

JSON Diff & Patch
A vision for how to build collaborative applications

TerminusDB CTO and Co-Founder, Gavin Mendel-Gleason, talks through data collaboration and how it should be done to build applications designed for collaboration.