Fix bug in JSON matcher.

The JSON matcher failed to detect unexpected results. Fixed that. Then some of the tests were failing; fortunately the tests were incorrect rather than the production code. Fixed those too.