Skip to content

v0.2.0

Choose a tag to compare

@nemanjatesic nemanjatesic released this 17 Feb 20:29
· 9 commits to main since this release

v0.2.0

New Features

CLI for comparing JSON objects and files

deep-obj-diff now ships with a command-line interface. Compare JSON files or inline strings directly from your terminal.

# Compare two JSON files
deep-obj-diff old.json new.json

# Compare inline JSON
deep-obj-diff '{"a":1,"b":2}' '{"a":1,"b":3,"c":4}'

# Use any output format
deep-obj-diff old.json new.json --format patch

CLI features:

  • Dual input modes — pass file paths or inline JSON strings
  • All output formats — list (default), flat, nested, patch, json
  • Rich options — --include-unchanged, --max-depth, --no-array-order, --filter, --json
  • Colorized output — respects NO_COLOR and FORCE_COLOR environment variables
  • CI-friendly — exits with code 1 when differences are found, 0 when identical
  • Modular structure — CLI code organized into src/cli/ (types, colors, input, printers, command)

Expand JSON-stringified strings (--expand-json-strings / -e)

String values containing valid JSON can now be recursively expanded before diffing, so their inner structure is compared rather than the raw string.

CLI:

deep-obj-diff old.json new.json -e

Programmatic:

import { diff } from 'deep-obj-diff';

diff(
  { data: '{"name":"Alice"}' },
  { data: '{"name":"Bob"}' },
  { expandJsonStrings: true }
);
// => [{ kind: 'changed', path: 'data.name', lhs: 'Alice', rhs: 'Bob' }]

The expandJsonStrings utility function is also exported for standalone use.

Bug Fixes

  • CI: build before test — fixed CI failure where CLI tests couldn't find dist/cli/index.js because tests ran before the build step
  • Windows compatibility — fixed npm test script failing on Windows by replacing node node_modules/.bin/jest with npx jest

Other Changes

  • Added 27 new tests (113 total, all passing)
  • Updated README with full CLI documentation
  • Coverage thresholds maintained (>80% across all metrics)

Install

npm install deep-obj-diff

# Or install globally for CLI access
npm install -g deep-obj-diff