{"record":{"id":"d3a3dd8da2fd1391","repo":"airbnb/lottie-android","slug":"expected-a-value-but-was-at-path","errorCode":null,"errorMessage":"Expected a value but was {} at path {}","messagePattern":"Expected a value but was (.+?) at path (.+?)","errorType":"exception","errorClass":"JsonDataException","httpStatus":null,"severity":"error","filePath":"lottie/src/main/java/com/airbnb/lottie/parser/moshi/JsonUtf8Reader.java","lineNumber":851,"sourceCode":"      throw new JsonDataException(\"Cannot skip unexpected \" + peek() + \" at \" + getPath());\n    }\n    int count = 0;\n    do {\n      int p = peeked;\n      if (p == PEEKED_NONE) {\n        p = doPeek();\n      }\n\n      if (p == PEEKED_BEGIN_ARRAY) {\n        pushScope(JsonScope.EMPTY_ARRAY);\n        count++;\n      } else if (p == PEEKED_BEGIN_OBJECT) {\n        pushScope(JsonScope.EMPTY_OBJECT);\n        count++;\n      } else if (p == PEEKED_END_ARRAY) {\n        count--;\n        if (count < 0) {\n          throw new JsonDataException(\n              \"Expected a value but was \" + peek() + \" at path \" + getPath());\n        }\n        stackSize--;\n      } else if (p == PEEKED_END_OBJECT) {\n        count--;\n        if (count < 0) {\n          throw new JsonDataException(\n              \"Expected a value but was \" + peek() + \" at path \" + getPath());\n        }\n        stackSize--;\n      } else if (p == PEEKED_UNQUOTED_NAME || p == PEEKED_UNQUOTED) {\n        skipUnquotedValue();\n      } else if (p == PEEKED_DOUBLE_QUOTED || p == PEEKED_DOUBLE_QUOTED_NAME) {\n        skipQuotedValue(DOUBLE_QUOTE_OR_SLASH);\n      } else if (p == PEEKED_SINGLE_QUOTED || p == PEEKED_SINGLE_QUOTED_NAME) {\n        skipQuotedValue(SINGLE_QUOTE_OR_SLASH);\n      } else if (p == PEEKED_NUMBER) {\n        buffer.skip(peekedNumberLength);","sourceCodeStart":833,"sourceCodeEnd":869,"githubUrl":"https://github.com/airbnb/lottie-android/blob/05ea92e90381eb8a8ae06855ea2b74f322bebbec/lottie/src/main/java/com/airbnb/lottie/parser/moshi/JsonUtf8Reader.java#L833-L869","documentation":"Thrown during skipValue() when a closing array bracket `]` (PEEKED_END_ARRAY) is encountered but the internal nesting counter has already reached zero (count < 0 at line 850). This means the JSON has an unbalanced bracket — there are more closing brackets than opening ones in the current scope being skipped.","triggerScenarios":"skipValue() is iterating through tokens and hits PEEKED_END_ARRAY when count is already 0. This happens when the JSON structure is malformed: an extra `]` appears, or a value was being skipped at the top level and the document structure is broken. The throw occurs at line 851.","commonSituations":"A truncated or corrupted Lottie JSON file where an array's closing bracket appears without a matching opening bracket. A minified JSON with missing brackets due to a transmission or encoding error. A Bodymovin plugin bug producing malformed array structures. Manual editing that removed an opening `[` but left the closing `]`.","solutions":["Validate the JSON with a JSON linter or parser (e.g., jsonlint.com, or org.json in Java) before passing it to Lottie to detect structural errors","Re-export the animation from After Effects to regenerate a well-formed JSON","If the JSON is truncated, ensure the full file is downloaded/read before parsing — check network integrity and file completeness","Catch JsonDataException during composition loading and show a fallback or error UI"],"exampleFix":"// before: {\"k\": [1, 2, 3]]}  // extra closing bracket\n// after:  {\"k\": [1, 2, 3]}","handlingStrategy":"validation","validationCode":"// Validate JSON structure balance before passing to Lottie\nboolean isJsonStructurallyValid(String json) {\n  try {\n    new org.json.JSONObject(json); // or JSONArray if top-level is array\n    return true;\n  } catch (org.json.JSONException e) {\n    // try as array\n    try {\n      new org.json.JSONArray(json);\n      return true;\n    } catch (org.json.JSONException e2) {\n      return false;\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  LottieCompositionFactory.fromJsonData(jsonData, cacheKey);\n} catch (JsonDataException e) {\n  Log.w(TAG, \"Structural error in Lottie JSON: \" + e.getMessage());\n  showFallbackAnimation();\n}","preventionTips":["Validate JSON with org.json or Gson before passing to Lottie","Ensure animation files are fully downloaded and not truncated","Re-export from After Effects if the JSON is structurally corrupt"],"tags":["json-parsing","moshi","lottie","malformed-json","structural-error"],"backgroundTag":null,"analyzedSha":"05ea92e90381eb8a8ae06855ea2b74f322bebbec","analyzedAt":"2026-08-14T00:51:35.636Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}