airbnb/lottie-android · error · JsonDataException
Expected a name but was {} at path {}
Error message
Expected a name but was {} at path {} What it means
JsonUtf8Reader.nextName() peeks the next token expecting one of the name token types (unquoted, double-quoted, single-quoted, or buffered name). If the token is not a name — e.g., it's a value, closing bracket, or EOF — it throws JsonDataException. This fires when the parser is inside an object and expects a property key but encounters a value or structural token instead.
Source
Thrown at lottie/src/main/java/com/airbnb/lottie/parser/moshi/JsonUtf8Reader.java:532
}
}
@Override public String nextName() throws IOException {
int p = peeked;
if (p == PEEKED_NONE) {
p = doPeek();
}
String result;
if (p == PEEKED_UNQUOTED_NAME) {
result = nextUnquotedValue();
} else if (p == PEEKED_DOUBLE_QUOTED_NAME) {
result = nextQuotedValue(DOUBLE_QUOTE_OR_SLASH);
} else if (p == PEEKED_SINGLE_QUOTED_NAME) {
result = nextQuotedValue(SINGLE_QUOTE_OR_SLASH);
} else if (p == PEEKED_BUFFERED_NAME) {
result = peekedString;
} else {
throw new JsonDataException("Expected a name but was " + peek() + " at path " + getPath());
}
peeked = PEEKED_NONE;
pathNames[stackSize - 1] = result;
return result;
}
@Override public int selectName(Options options) throws IOException {
int p = peeked;
if (p == PEEKED_NONE) {
p = doPeek();
}
if (p < PEEKED_SINGLE_QUOTED_NAME || p > PEEKED_BUFFERED_NAME) {
return -1;
}
if (p == PEEKED_BUFFERED_NAME) {
return findName(peekedString, options);
}
View on GitHub (pinned to 05ea92e903)
Solutions
- Use the exception path to locate the malformed object in the JSON and fix the property key-value structure.
- Run the JSON through a validator/linter.
- Re-export or re-download the animation file.
Defensive patterns
Strategy: try-catch
Try / catch
LottieTask<LottieComposition> task = LottieCompositionFactory.fromAsset(context, name);
task.addListener(result -> { /* success */ })
.addFailureListener(e -> { /* JSON property name error */ }); Prevention
- Validate Lottie JSON object structure with a linter.
- Use async LottieCompositionFactory APIs.
- Re-export or re-download corrupted animations.
When it happens
Trigger: Inside a JSON object, the parser expects a property name but finds a value, closing brace, comma, or EOF. This happens when object key-value pairs are malformed — e.g., a missing key before a value, or an extra value after the last property.
Common situations: Corrupted or hand-edited Lottie JSON with object key-value errors; truncated file; malformed export from a non-standard tool.
Related errors
- Expected BEGIN_ARRAY but was {} at path {}
- Expected END_ARRAY but was {} at path {}
- Expected BEGIN_OBJECT but was {} at path {}
- Expected END_OBJECT 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/8ef27153d488c0eb.
Report an issue: GitHub.