{"record":{"id":"2ef9967f3c8e2a82","repo":"airbnb/lottie-android","slug":"expected-begin-object-but-was-at-path","errorCode":null,"errorMessage":"Expected BEGIN_OBJECT but was {} at path {}","messagePattern":"Expected BEGIN_OBJECT 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":150,"sourceCode":"      stackSize--;\n      pathIndices[stackSize - 1]++;\n      peeked = PEEKED_NONE;\n    } else {\n      throw new JsonDataException(\"Expected END_ARRAY but was \" + peek()\n          + \" at path \" + getPath());\n    }\n  }\n\n  @Override public void beginObject() throws IOException {\n    int p = peeked;\n    if (p == PEEKED_NONE) {\n      p = doPeek();\n    }\n    if (p == PEEKED_BEGIN_OBJECT) {\n      pushScope(JsonScope.EMPTY_OBJECT);\n      peeked = PEEKED_NONE;\n    } else {\n      throw new JsonDataException(\"Expected BEGIN_OBJECT but was \" + peek()\n          + \" at path \" + getPath());\n    }\n  }\n\n  @Override public void endObject() throws IOException {\n    int p = peeked;\n    if (p == PEEKED_NONE) {\n      p = doPeek();\n    }\n    if (p == PEEKED_END_OBJECT) {\n      stackSize--;\n      pathNames[stackSize] = null; // Free the last path name so that it can be garbage collected!\n      pathIndices[stackSize - 1]++;\n      peeked = PEEKED_NONE;\n    } else {\n      throw new JsonDataException(\"Expected END_OBJECT but was \" + peek()\n          + \" at path \" + getPath());\n    }","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/airbnb/lottie-android/blob/05ea92e90381eb8a8ae06855ea2b74f322bebbec/lottie/src/main/java/com/airbnb/lottie/parser/moshi/JsonUtf8Reader.java#L132-L168","documentation":"JsonUtf8Reader.beginObject() peeks the next token and expects PEEKED_BEGIN_OBJECT ('{'). If the token is anything else, it throws JsonDataException. This occurs when the Lottie parser expects a JSON object at a specific path but finds a different type — e.g., a layer definition that should be an object is instead an array or primitive.","triggerScenarios":"A field expected to be a JSON object (layer, keyframe, transform, etc.) is instead an array, string, number, or null. This means the JSON structure does not match the Lottie schema at that location.","commonSituations":"Non-standard Lottie JSON export; corrupted or hand-edited file where object braces were removed; version incompatibility between the animation format and the library.","solutions":["Use the path from the exception to locate the offending field and verify it is a JSON object as expected.","Validate with LottieFiles validator and a JSON schema checker.","Re-export the animation from a compatible tool version."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"LottieTask<LottieComposition> task = LottieCompositionFactory.fromAsset(context, name);\ntask.addListener(result -> { /* success */ })\n     .addFailureListener(e -> { /* JSON object structure error */ });","preventionTips":["Validate Lottie JSON structure with LottieFiles validator.","Use async LottieCompositionFactory APIs for graceful error handling.","Re-export from supported tool versions."],"tags":["lottie","json-parsing","type-mismatch","object","json-data-exception"],"backgroundTag":null,"analyzedSha":"05ea92e90381eb8a8ae06855ea2b74f322bebbec","analyzedAt":"2026-08-14T00:51:35.636Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}