Closed poiu144 closed 3 months ago
I'm pretty sure no other JSON library compares [1,2,3,4] equal to [2,3,1,4]! They're arrays, not sets. Order matters.
If that's something you wanted, you'd need to write your own non-member function to compare them that way.
Describe the proposed feature
We can use new overloading operator== to deal with the equality problem of multiple nested arrays and objects. I hope you can add this choice for users, though we don't expect [1,2,3,4] equal to [2,3,1,4] in some cases.
I will briefly talk about my idea of the solution:
When I searched for the implement of operator ==,I noticed you call compare() to achieve the judgement of equality. And then, recursive call. But in the case "json_storage_kind::array_value", you use class array_storage to compare array_value, so the comparison is changed to the equality of two ptr which becomes a comparison of two vectors at last. I wondered if we sort the vectors before compare them, we can see the occurrence of [1,2,3,4] being equal to [2,1,4,3].
What other libraries (C++ or other) have this feature?
idk :)
Include a code fragment with sample data that illustrates the use of this feature
Maybe a sample is as follows: jstr1= [{"1":[1,2,3,4],"2":2,"3":3},{"4":4}] jstr2 = [{"4":4}, {"1":[4,1,2,3],"2":2,"3":3}]
Hope you can consider this need. Appreciate it so much. Peace.