Closed Halynsky closed 11 months ago
In the version 1.2.6 of the software, all paths are treated as regular expressions, this was an issue. However, this approach has been revised in version 2 (ECMAScript Module). In consider for a future update to consider "" and "." to consider as root. Currently onlöy "" works as root.
In the context of how it's supposed to work, the notation {"": "id", "children": "name"}
is correct. However, in version 1.2.6, the path children
would be interpreted as /children/
, matching any path containing the word "children". To precisely match the 'children' property of the root in version 1.2.6, it's recommended to use the regular expression ^children$
.
Additionally, both versions allow the specification of a function to resolve the key for comparsion and name of the key, as detailed in the documentation of version 2. This functionality is also present in version 1.2.6.
Fixes in #108
The goal is to compare 2 arrays. As I see in the source, this library should be capable to do that. But there is an issue with key of elements. For example we have 2 arrays and we want to specify that uniqueness key is - id. But in the options we can specify only embeddedObjKeys. I am not sure that it's by design but I found such kind of workaround with empty key of embeddedObjKeys dictionary:
But the issue is that it inner arrays becomes also be tracked by id. So this code will not give any changes.
So if we add id for children. It works more correctly and show the changes. (But for example I have a case where children don't have an id)
Another option that also works is to specify children key. I think it kind of override. -
{"": "id", "children": "name"}
. But this is not very good for big and complicated objects with many child arrays.Suggestions: Would be nice to have a way to specify just a key for array. And this key should be not used by child array. Way how it specified now is ok but at least need to be documented. Alternatives: {".": "id"} or {"$root": "id"}