You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry, if I'm not using the library the best way. I have just started to use it today.
Instead of using the operators, it maybe nicer to extend the json object to have a .contains method (or several depending on parameters).
Also, it would be nice to consider providing options like "arrays might be in the same order" or take some considerations on duplicated keys, ...
I'd like to use this function for testing. For example, I want to know if the JSON returned by a function contains at least the keys I expect it to have even if it has more or in a different order and with the values and types I expect.
The text was updated successfully, but these errors were encountered:
I do not like overloading operator&& as this would be really surprising behavior.
I think the usecase is really specific; as you demonstrated that it is possible to realize in client code, I do not see the need to add this to the library.
I guess defining equality with JSON objets is very tricky. It would be useful if there was an RFC or something that defines first what is a useful way of comparing.
I first attempted to use the diff function to generate a patch and check only adds operations are generated but it is unfortunately not the minimum patch so that didn’t work.
I ended up creating a function instead of the operator and having a parameter to take the array order into account or not. That is sufficient for our needs at the moment.
I initially thought about the operator& but I really didn’t like the idea that much but
it makes me think though on what operations make sense with JSON objects like merging JSON objects by using operator+ etc.
Anyways, thank you for your feedback and consideration of the feature and, by the way, your library is really outstanding. Thank you for sharing.
It would be nice to include as part of the library a way to compare JSON object in a way that the order is not important.
I though maybe defining operator&& to do it.
Obviously, this example is very simple but it could work with more complex objects.
This could be a very simplistic implementation:
Sorry, if I'm not using the library the best way. I have just started to use it today.
Instead of using the operators, it maybe nicer to extend the json object to have a .contains method (or several depending on parameters).
Also, it would be nice to consider providing options like "arrays might be in the same order" or take some considerations on duplicated keys, ...
I'd like to use this function for testing. For example, I want to know if the JSON returned by a function contains at least the keys I expect it to have even if it has more or in a different order and with the values and types I expect.
The text was updated successfully, but these errors were encountered: