It would be nice to check wether one json blob is contained by other blob. i.e. given the json blob a and the blob b, a contains b if every key x in b is also in a, and b[x] == a[x] if b[x] is not a json object itself or, if it is a json object, a[x] contains b[x].
One of the most useful patterns while testing functions which return json, is to write the expected result and then compare if the expected blob is equal to the returned one:
As can be seen in the example above, it is easy to read what the expected value is, and checking for failures if fairly easy.
It is no easy, however, to compare returned blobs which contain at least one random values (for example time stamps), or a value which is uninteresting for the test. In such cases it is necessary to extract each value separately and compare them:
As seen above, is one is only interested in a subset of the keys/values pairs returned by bar the readability of the code decreases severely. It is worse if it weren't for the comments.
The aim is to achieve the same level of readability on the first example while covering the case of the second: