{
  "id": "flutter/dart-format-exception-json-decode",
  "signature": "FormatException: Unexpected character (at character 2)",
  "signature_zh": "FormatException: 意外字符（位于字符 2）",
  "regex": "FormatException: Unexpected character \\(at character \\d+\\)",
  "domain": "flutter",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Invalid JSON string received from a network request or local file, possibly truncated or malformed.",
  "root_cause_type": "generic",
  "root_cause_zh": "从网络请求或本地文件接收到的 JSON 字符串无效，可能被截断或格式错误。",
  "versions": [
    {
      "version": "Flutter 3.22.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Dart 3.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "http 1.2.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "dio 5.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Ignoring the error leaves the app in an inconsistent state with null data, causing downstream crashes.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The format exception is raised by Dart's standard decoder; other libraries use the same parser.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The error is about JSON syntax, not character encoding; changing encoding may worsen the issue.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Log the raw response body before decoding to inspect the actual content: `print(response.body);` and check for truncation or extra characters.",
      "success_rate": 0.95,
      "how": "Log the raw response body before decoding to inspect the actual content: `print(response.body);` and check for truncation or extra characters.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a JSON preprocessor to remove BOM or control characters: `String cleaned = response.body.replaceAll(RegExp(r'[\\x00-\\x1F\\x7F]'), '');` then decode.",
      "success_rate": 0.8,
      "how": "Use a JSON preprocessor to remove BOM or control characters: `String cleaned = response.body.replaceAll(RegExp(r'[\\x00-\\x1F\\x7F]'), '');` then decode.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a retry mechanism with exponential backoff for network requests to handle transient truncation.",
      "success_rate": 0.7,
      "how": "Add a retry mechanism with exponential backoff for network requests to handle transient truncation.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Log the raw response body before decoding to inspect the actual content: `print(response.body);` and check for truncation or extra characters.",
    "Use a JSON preprocessor to remove BOM or control characters: `String cleaned = response.body.replaceAll(RegExp(r'[\\x00-\\x1F\\x7F]'), '');` then decode.",
    "Add a retry mechanism with exponential backoff for network requests to handle transient truncation."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://api.dart.dev/stable/3.4.0/dart-convert/FormatException-class.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}