Improved sanity_check_json function.