json-diff-ts icon indicating copy to clipboard operation
json-diff-ts copied to clipboard

compare on arrays produces an unexpected UNCHANGED entry

Open YoungFrog opened this issue 4 months ago • 0 comments

Consider the following :

import { compare } from 'json-diff-ts'

console.log(compare(["foo"], ["bar"]))

The result is :

{ type: 'CONTAINER', value: [ { type: 'UNCHANGED', value: 'foo' }, '$root': [ [Object] ] ] }

(the actual change is hidden inside the $root key) Is this intended ?

It seems inconsistent with what happens for objects :

import { compare } from 'json-diff-ts'

console.log(compare({ "k": "foo" }, { "k": "bar" }))

{ type: 'CONTAINER', value: { k: { type: 'UPDATE', value: 'bar', oldValue: 'foo' } } }

YoungFrog avatar Nov 03 '25 10:11 YoungFrog