Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omgaz/diffler
A recursive JSON comparison script for humans
https://github.com/omgaz/diffler
compare hacktoberfest javascript jsdiff json json-objects
Last synced: 16 days ago
JSON representation
A recursive JSON comparison script for humans
- Host: GitHub
- URL: https://github.com/omgaz/diffler
- Owner: omgaz
- License: mit
- Created: 2012-05-10T10:10:15.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T21:57:06.000Z (over 1 year ago)
- Last Synced: 2024-09-20T12:18:01.050Z (about 2 months ago)
- Topics: compare, hacktoberfest, javascript, jsdiff, json, json-objects
- Language: JavaScript
- Homepage:
- Size: 341 KB
- Stars: 18
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
diffler
A recursive JSON comparison script for humans
## Motivation
To compare JSON objects containing asset metadata for a digital library. Upon change of any metadata, we'd store these changes as an audit trail and email asset stakeholders for review and approval of the changes.
## Dependencies
diffler is written with Node v12 in mind.
Tests depend on [Mocha](https://mochajs.org/).## Usage
[![npm version](https://badge.fury.io/js/diffler.png)](https://www.npmjs.com/package/diffler)
```bash
npm install diffler
```### Params
`obj1` and `obj2` are two JSON objects for comparison.
### Return
If same: returns `{}` _(empty object)_
If different: A JSON object with preserved path structure. The resulting values will be an object with `from` and `to` fields.
### Example
```js
const diffler = require("diffler");const before = { name: "omgaz", location: "London" };
const after = { name: "omgaz", location: "Melbourne" };const difference = diffler(before, after);
console.log(difference); // { location: { from: "London", to: "Melbourne" } }
```## Tests
[![Build Status](https://travis-ci.org/omgaz/diffler.svg?branch=master)](https://travis-ci.org/omgaz/diffler)
If you'd like to run tests, check out the whole project. You'll need NodeJS installed. Tests use Mocha.
```bash
npm install
npm test
```