Extension to match two objects, using partial equality.
For example, an object with the following properties:
{"A": 123,"B": "some value""C":[ 100, 200, 300]}
Will match the following objects, because any non-default values are equal:{ "A": 123 } or { "B": "some value" } or { "C":[ 100, 200, 300] }
Whereas it will NOT match these objects, because they have fields that don't match:
{ "A": 456 } or { "B": "some other value" } or { "C":[ 100, 200, 300, 400] } or { D: 123 }
This code is very useful in Testing, where we want to compare an actual and an expected result, but only on some attributes, not all.
MatchJSON is now also a function