Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xucongli1989/json-structure-compare
This is a json structure compare tool,you can input two json data and run node script to get a comparative report via Beyond Compare.
https://github.com/xucongli1989/json-structure-compare
json json-compare json-structure-compare node
Last synced: about 1 month ago
JSON representation
This is a json structure compare tool,you can input two json data and run node script to get a comparative report via Beyond Compare.
- Host: GitHub
- URL: https://github.com/xucongli1989/json-structure-compare
- Owner: xucongli1989
- License: mit
- Created: 2018-05-25T09:23:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-30T02:57:39.000Z (over 6 years ago)
- Last Synced: 2024-11-19T22:02:54.217Z (about 2 months ago)
- Topics: json, json-compare, json-structure-compare, node
- Language: TypeScript
- Size: 1.34 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
## Introduction
This is a json structure compare tool,you can input two json data and run node script to get a comparative report via Beyond Compare.## Start
- Create your project,and it has `./dist/` directory
- `npm install json-structure-compare --save-dev`
- Create file `./test.js` and write your code like this
let moduleInfo = require('json-structure-compare');
let obj = new moduleInfo.Compare({
dataA: { "a": "test" },
dataB: { "b": "test" },
beyondComparePath: "C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe",
outputPath: "./dist/"
});
obj.run();- Run script `node test.js`
- So,you will get your comparative result,see your console's log.
## Config Options
/**
* The default config.
*/
interface IDefaultConfig {
/**
* Beyond Compare soft path.
*/
beyondComparePath: string
/**
* Your work space for output
*/
outputPath: string
/**
* Json A to compare.
*/
dataA: IAnyPropObject
/**
* Json B to compare.
*/
dataB: IAnyPropObject
}The default value is:
let defaultConfig: IDefaultConfig = {
beyondComparePath: "C:\\Program Files\\Beyond Compare 4\\BComp.exe",
outputPath: path.resolve("./dist/"),
dataA: data.a,
dataB: data.b
}## Theory
- Convert json object to path string array with keys,like `["A.B","A.B.C","A.B.C.D",...]`
- Compare the lines use Beyond Compare tool.
- Notice:If one key is `Array` ,then compare the first item only.
## Demo Result Preview
![](https://raw.githubusercontent.com/xucongli1989/json-structure-compare/master/img.jpg)