Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The JSON object contains an array of data returned incorrectly #9

Open
vxhly opened this issue Nov 4, 2017 · 2 comments
Open

The JSON object contains an array of data returned incorrectly #9

vxhly opened this issue Nov 4, 2017 · 2 comments

Comments

@vxhly
Copy link

vxhly commented Nov 4, 2017

var diff = require('rus-diff').diff
var config1 = require('./config1.json')
var config2 = require('./config2.json')

var a = {
  bar: [
    {
      bar2: 2,
      zz: 2
    }
  ]
}

var b = {
  bar: [
    {
      bar2: 2,
      zz: 3
    }
  ]
}

console.log(diff(a, b))

The program return

{ '$set': { bar: [ [Object] ] } }

so, Objects in the array can not be compared

@xiongbinsh
Copy link

@vxhly why not try:
result=diff(a,b);
then print out result.$set.bar. it is the right answer [ { bar2: 2, zz: 3 } ] .

in one word, console.log hides what u want to see.

@vxhly
Copy link
Author

vxhly commented Mar 14, 2018

Thank you!But I have changed one method. @xiongbinsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants