airbnb/lottie-android · error · JsonDataException
Expected END_OBJECT but was {} at path {}
Error message
Expected END_OBJECT but was {} at path {} What it means
JsonUtf8Reader.endObject() peeks the next token and expects PEEKED_END_OBJECT ('}'). If it encounters a different token, it throws JsonDataException with the actual token and path. This fires when the parser finishes reading an object's properties but the JSON does not properly terminate the object with a closing brace.
Source
Thrown at lottie/src/main/java/com/airbnb/lottie/parser/moshi/JsonUtf8Reader.java:166
peeked = PEEKED_NONE;
} else {
throw new JsonDataException("Expected BEGIN_OBJECT but was " + peek()
+ " at path " + getPath());
}
}
@Override public void endObject() throws IOException {
int p = peeked;
if (p == PEEKED_NONE) {
p = doPeek();
}
if (p == PEEKED_END_OBJECT) {
stackSize--;
pathNames[stackSize] = null; // Free the last path name so that it can be garbage collected!
pathIndices[stackSize - 1]++;
peeked = PEEKED_NONE;
} else {
throw new JsonDataException("Expected END_OBJECT but was " + peek()
+ " at path " + getPath());
}
}
@Override public boolean hasNext() throws IOException {
int p = peeked;
if (p == PEEKED_NONE) {
p = doPeek();
}
return p != PEEKED_END_OBJECT && p != PEEKED_END_ARRAY && p != PEEKED_EOF;
}
@Override public Token peek() throws IOException {
int p = peeked;
if (p == PEEKED_NONE) {
p = doPeek();
}
View on GitHub (pinned to 05ea92e903)
Solutions
- Use the exception path to locate the malformed object and ensure it is properly closed with '}'.
- Validate the JSON structure with a linter.
- Re-download or re-export the animation.
Defensive patterns
Strategy: try-catch
Try / catch
LottieTask<LottieComposition> task = LottieCompositionFactory.fromAsset(context, name);
task.addListener(result -> { /* success */ })
.addFailureListener(e -> { /* JSON object structure error */ }); Prevention
- Validate Lottie JSON with a JSON linter.
- Use async APIs to handle parse failures gracefully.
- Re-export or re-download corrupted animations.
When it happens
Trigger: The parser expects '}' but finds a continuation token — a property name, value, or comma — indicating extra properties, a missing delimiter, or structural corruption within an object.
Common situations: Corrupted Lottie JSON with missing closing braces; hand-edited JSON with structural errors; truncated file where the parser reads past available data into an unexpected token.
Related errors
- Expected BEGIN_OBJECT but was {} at path {}
- Expected BEGIN_ARRAY but was {} at path {}
- Expected END_ARRAY but was {} at path {}
- Expected a name but was {} at path {}
- Expected a string but was {} at path {}
AI-assisted analysis of airbnb/lottie-android@05ea92e903 (2026-08-14).
Data as JSON: /api/errors/be26eda3925c59bc.
Report an issue: GitHub.