Closed givascu closed 4 years ago
When comparing objects, the key ordering shouldn't matter. If it currently does, that's a bug.
When comparing objects, the key ordering shouldn't matter. If it currently does, that's a bug.
Right, I hastily misread that bit. My point still stands for array elements though. Thanks.
P.S. Feel free to edit the issue in any way.
IMHO, it should be up to the user to do their own unordered comparison if that's something they need. If jansson does it, then it'll have to decide between:
That said, if @akheron is interested in adding a naive json_array_equal_unordered()
(or something like that) convenience function (or macro?) that does a simple exhaustive search of the array, I'd be willing to try writing a PR for it.
I don't think using arrays in such a way should be a feature of Jansson. That's just not how arrays are meant to be used.
From the documentation:
The current implementation of
json_equal()
compares strictly against the order of object keys or array elements.As a user, I want to be able to compare JSONs regardless of the ordering of object keys or array elements. To not break the API backward-compatibility, a new function can be added. Some naming suggestions:
json_equivalent()
,json_is_same()
,json_equal_deep()
, etc.