Added a safety check that the JSON validation is internally consistent