Move parse_and_validate_json to a utility module.