airbnb/lottie-android · error · JsonEncodingException

{} at path {}

Error message

{} at path {}

What it means

JsonReader.syntaxError(String) is a helper method that appends the current JSON path to a message and throws JsonEncodingException. It is called from many places in the JSON reader whenever the stream structure violates JSON syntax rules (unexpected tokens, malformed literals, etc.). The specific message passed to syntaxError() identifies the exact violation, and the path tells you where in the JSON document it occurred.

Source

Thrown at lottie/src/main/java/com/airbnb/lottie/parser/moshi/JsonReader.java:251

  final void pushScope(int newTop) {
    if (stackSize == scopes.length) {
      if (stackSize == 256) {
        throw new JsonDataException("Nesting too deep at " + getPath());
      }
      scopes = Arrays.copyOf(scopes, scopes.length * 2);
      pathNames = Arrays.copyOf(pathNames, pathNames.length * 2);
      pathIndices = Arrays.copyOf(pathIndices, pathIndices.length * 2);
    }
    scopes[stackSize++] = newTop;
  }

  /**
   * Throws a new IO exception with the given message and a context snippet
   * with this reader's content.
   */
  final JsonEncodingException syntaxError(String message) throws JsonEncodingException {
    throw new JsonEncodingException(message + " at path " + getPath());
  }


  /**
   * Consumes the next token from the JSON stream and asserts that it is the beginning of a new
   * array.
   */
  public abstract void beginArray() throws IOException;

  /**
   * Consumes the next token from the JSON stream and asserts that it is the
   * end of the current array.
   */
  public abstract void endArray() throws IOException;

  /**
   * Consumes the next token from the JSON stream and asserts that it is the beginning of a new
   * object.

View on GitHub (pinned to 05ea92e903)

Solutions

  1. Use the path in the exception message to locate the error in the JSON file and fix the syntax violation.
  2. Validate the JSON with a standard JSON parser/linter to identify structural errors.
  3. Re-download or re-export the animation file to eliminate corruption or encoding issues.
Defensive patterns

Strategy: try-catch

Try / catch

LottieTask<LottieComposition> task = LottieCompositionFactory.fromAsset(context, name);
task.addListener(result -> { /* success */ })
     .addFailureListener(e -> {
         if (e instanceof JsonEncodingException) {
             // JSON syntax error — file is corrupted
         }
     });

Prevention

When it happens

Trigger: Any structural JSON syntax violation encountered during parsing: malformed escape sequences, premature EOF, unexpected delimiters, invalid number literals, etc. The exact trigger depends on which call site invoked syntaxError().

Common situations: Corrupted or truncated Lottie JSON file; hand-edited JSON with syntax errors; incomplete file download; encoding issues (e.g., BOM characters, non-UTF-8 encoding).

Related errors


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