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 valuesAPI
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 thesourceObject.
Returns:
- A
booleanvalue. true: If bothsourceObjectandtargetObjectare structurally identical and have the same content.false: If any differences in structure or content are found.
- A
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.