visualize json difference
This project helps visualize the differences between two JSON objects. It provides a clear and intuitive interface to compare and identify changes in JSON data structures.
This is an NPM package. You can install it using npm:
npm install jsondiff
Import the JSONDiff
class into your project:
// ES6 module
import JSONDiff from 'jsondiff';
// CommonJS
// const JSONDiff = require('jsondiff');
Then, instantiate JSONDiff
with a container element and the JSON data to compare:
const diffViewer = new JSONDiff({
container: document.getElementById('my-diff-container'), // or any other DOM element
data: {
base: { /* your first JSON object */ },
test: { /* your second JSON object to compare */ }
}
});
The necessary CSS styles are compiled from jsondiff.less
and bundled with the JavaScript during the build process. If you are importing the module, you typically do not need to include a separate CSS file.
The following scripts are available for development:
npm run build
: Builds the project for production. This command setsNODE_ENV=production
and runs webpack with progress and production optimizations (-p
).npm run dev
: Starts the webpack development server. This command setsNODE_ENV=dev
and opens the application in your default browser.
This project is licensed under the MIT License.
craigzeng
Contributions are welcome! Please refer to the repository's issue tracker and pull request guidelines.
You can find the source code and contribute to the project on GitHub: https://github.com/CraigZeng/jsondiff