ubitricity / snapshotter

MIT License
8 stars 2 forks source link

JSONassert fails on ignoring object fields in array #5

Open bartlomiejlazarczyk opened 2 years ago

bartlomiejlazarczyk commented 2 years ago

https://github.com/skyscreamer/JSONassert/issues/109

Unfortunately, JSONassert library used in snapshotter has an annoying issue therefore it is not possible to ignore fields in arrays. It seems that a fix for this problem is already implemented and exposed as a PR but JSONassert is not maintained anymore. It will be good to replace it with another solution.

pmajcher commented 2 years ago

Hi @bartlomiejlazarczyk, please use the following config to ignore all ids in a whole json (java example):

new ValidationConfig.Builder()
        .ignore("**.id")
        .build();
bartlomiejlazarczyk commented 2 years ago

Yes, it works but only for an array that has only one element.

Under the hood snapshotter use JSONCompareMode.NON_EXTENSIBLE mode, which is not strict when it comes to the order of an array. Probably the problem lies there, in the previously mentioned issue there are some comments about JSONCompareMode.STRICT mode working fine.

Nonetheless as far as I recall, being not strict about array order was one of the drivers for snapshotter. In order to keep that, there might be a need for replacing it with another solution.