Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Created December 5, 2015 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bessarabov/aff0440f5ef3bda9afe2 to your computer and use it in GitHub Desktop.
Save bessarabov/aff0440f5ef3bda9afe2 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var dataDiff = require('data-diff');
var one = fs.readFileSync('one.json');
var two = fs.readFileSync('two.json');
var diff = dataDiff(JSON.parse(one), JSON.parse(two));
console.log(diff);
@katspaugh
Copy link

readFileSync возвращает буффер, а не строку.
Используй лучше require("./one.json"), он выдаёт сразу распарсенный JSON-объект.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment