andreyvit/json-diff

input array in deep object,but output object

halberlink opened this issue · 1 comments

a.json
"settings": { "react": { "version": "detect" // Tells eslint-plugin-react to automatically detect the version of React to use }, "import/resolver": { "node": { "extensions": [ ".js", ".jsx", ".tsx" ] }, // 解决tsconfig下的path别名导致eslint插件无法解决的bug "typescript": { "directory": "." } } }
b.json
"settings": { "react": { "version": "detect" // Tells eslint-plugin-react to automatically detect the version of React to use }, "import/resolver": { "node": { "extensions": [ ".js", ".jsx" ] }, // 解决tsconfig下的path别名导致eslint插件无法解决的bug "typescript": { "directory": "." } } }

console.log(jsonDiff.diffString(a, b);
output:

image

why extenstions become an object ?

This works properly in 0.6.0:

$ cat a.json
{
  "settings": {
    "react": { "version": "detect" },
    "import/resolver": {
      "node": { "extensions": [".js", ".jsx", ".tsx"] },
      "typescript": { "directory": "." }
    }
  }
}
$ cat b.json
{
  "settings": {
    "react": { "version": "detect" },
    "import/resolver": {
      "node": { "extensions": [".js", ".jsx"] },
      "typescript": { "directory": "." }
    }
  }
}
$ json-diff  a.json b.json
 {
   settings: {
     import/resolver: {
       node: {
         extensions: [
           ...
           ...
-          ".tsx"
         ]
       }
     }
   }
 }
$ json-diff --full a.json b.json
 {
   settings: {
     react: {
       version: "detect"
     }
     import/resolver: {
       node: {
         extensions: [
           ".js"
           ".jsx"
-          ".tsx"
         ]
       }
       typescript: {
         directory: "."
       }
     }
   }
 }