node-rus-diff icon indicating copy to clipboard operation
node-rus-diff copied to clipboard

The JSON object contains an array of data returned incorrectly

Open vxhly opened this issue 8 years ago • 2 comments

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

vxhly avatar Nov 04 '17 06:11 vxhly

@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.

xiongbinsh avatar Mar 14 '18 06:03 xiongbinsh

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

vxhly avatar Mar 14 '18 06:03 vxhly