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

  1. Use the exception path to locate the malformed object and ensure it is properly closed with '}'.
  2. Validate the JSON structure with a linter.
  3. 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

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


AI-assisted analysis of airbnb/lottie-android@05ea92e903 (2026-08-14). Data as JSON: /api/errors/be26eda3925c59bc. Report an issue: GitHub.