{"meta":{"title":"Debugging invalid JSON","intro":"Discussion avec Copilot can identify and resolve syntax errors or structural issues in JSON data.","product":"GitHub Copilot","breadcrumbs":[{"href":"/fr/enterprise-cloud@latest/copilot","title":"GitHub Copilot"},{"href":"/fr/enterprise-cloud@latest/copilot/tutorials","title":"Tutoriels"},{"href":"/fr/enterprise-cloud@latest/copilot/tutorials/copilot-cookbook","title":"GitHub Copilot Cookbook"},{"href":"/fr/enterprise-cloud@latest/copilot/tutorials/copilot-cookbook/debug-errors","title":"Erreurs de débogage"},{"href":"/fr/enterprise-cloud@latest/copilot/tutorials/copilot-cookbook/debug-errors/debug-invalid-json","title":"Debug invalid JSON"}],"documentType":"article"},"body":"# Debugging invalid JSON\n\nDiscussion avec Copilot can identify and resolve syntax errors or structural issues in JSON data.\n\nWhen working with JSON data, you may encounter issues such as trailing commas, mismatched braces, or incorrect data types that make the JSON invalid. GitHub Copilot Chat can help you debug and fix these errors by suggesting corrections to fix invalid JSON.\n\n## Example scenario\n\nConsider a scenario where an application consumes JSON data from an API, but the response fails to parse due to invalid formatting. You receive the error message:\n\n```bash\nError: Parse error\n----------------------^\nExpecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'\n```\n\nBelow is the JSON data that caused the error:\n\n```json id=json-error\n{\n  \"location\": \"San Francisco\",\n  \"current_weather\": {\n    \"temperature\": 18,\n    \"unit\": \"Celsius\",\n    \"conditions\": \"Cloudy\n  },\n  \"forecast\": {\n    \"day\": \"Monday\",\n    \"high\": 22,\n    \"low\": 15,\n    \"precipitation\": 10\n  }\n}\n```\n\n## Example prompt\n\n```copilot copy prompt ref=json-error\nWhy is my JSON object invalid and how can I fix it?\n```\n\n## Example response\n\n> \\[!NOTE] La réponse suivante est un exemple. Les réponses Discussion avec Copilot ne sont pas déterministes, vous pouvez donc obtenir une réponse différente de celle affichée ici.\n\nCopilot might suggest that your JSON is invalid because it's missing a closing quote for the `conditions` value. Here is the corrected JSON:\n\n```json\n{\n  \"location\": \"San Francisco\",\n  \"current_weather\": {\n    \"temperature\": 18,\n    \"unit\": \"Celsius\",\n    \"conditions\": \"Cloudy\"\n  },\n  \"forecast\": {\n    \"day\": \"Monday\",\n    \"high\": 22,\n    \"low\": 15,\n    \"precipitation\": 10\n  }\n}\n```\n\nIn this example response, Copilot's suggestions include fixing the closing quote for the `conditions` value, which resolves the JSON parsing error.\n\n## Further reading\n\n* [Ingénierie rapide pour GitHub Copilot Chat](/fr/enterprise-cloud@latest/copilot/using-github-copilot/prompt-engineering-for-github-copilot)\n* [Meilleures pratiques pour l’utilisation de GitHub Copilot](/fr/enterprise-cloud@latest/copilot/using-github-copilot/best-practices-for-using-github-copilot)"}