JSPM

@tzm96dev/deep-json-diff

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 28
  • Score
    100M100P100Q49198F
  • License ISC

A utility to perform deep comparison of JSON objects to find differences.

Package Exports

  • @tzm96dev/deep-json-diff
  • @tzm96dev/deep-json-diff/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@tzm96dev/deep-json-diff) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@tzm96dev/deep-json-diff

@tzm96dev/deep-json-diff is a JavaScript utility function designed to perform a deep comparison between two JSON objects to determine if they are identical in structure and content. It evaluates each property by navigating recursively through both objects and reports any discrepancies.

Features

  • Deep Recursive Comparison: Thoroughly compares all levels and properties of two JSON objects.
  • Detailed Discrepancies: Outputs precise paths and descriptions where differences occur.
  • Type and Structure Verification: Ensures consistency in types and data structure between the compared objects.

Installation

You can install @tzm96dev/deep-json-diff using npm:

npm install @tzm96dev/deep-json-diff
Usage
Here's how to use @tzm96dev/deep-json-diff to compare two JSON objects, where sourceObject is the base object and targetObject is the object being compared:

javascript
Copy code
import deepJsonDiff from '@tzm96dev/deep-json-diff';

const sourceObject = {
  user: {
    name: "Alice",
    age: 25,
    interests: ["reading", "cycling", "technology"]
  }
};

const targetObject = {
  user: {
    name: "Alice",
    age: 25,
    interests: ["reading", "biking", "tech"]
  }
};

const areIdentical = deepJsonDiff(sourceObject, targetObject);
console.log(areIdentical); // Output: false, due to differences in 'interests' array and values

API

deepJsonDiff(sourceObject: ObjectWithAnyValues, targetObject: ObjectWithAnyValues): boolean

  • Parameters:

    • sourceObject: The base or reference JSON object against which the comparison is made.
    • targetObject: The JSON object to be compared with the sourceObject.
  • Returns:

    • A boolean value.
    • true: If both sourceObject and targetObject are structurally identical and have the same content.
    • false: If any differences in structure or content are found.

Contributing

Contributions are always welcome! If you would like to enhance @tzm96dev/deep-json-diff, feel free to open an issue or submit a pull request on the GitHub repository.


License

This project is distributed under the MIT License. For more information, please refer to the LICENSE file.