{"record":{"id":"dd89bceecd6304d4","repo":"airbnb/lottie-android","slug":"expected-a-double-but-was-at-path","errorCode":null,"errorMessage":"Expected a double but was {} at path {}","messagePattern":"Expected a double 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":678,"sourceCode":"      p = doPeek();\n    }\n\n    if (p == PEEKED_LONG) {\n      peeked = PEEKED_NONE;\n      pathIndices[stackSize - 1]++;\n      return (double) peekedLong;\n    }\n\n    if (p == PEEKED_NUMBER) {\n      peekedString = buffer.readUtf8(peekedNumberLength);\n    } else if (p == PEEKED_DOUBLE_QUOTED) {\n      peekedString = nextQuotedValue(DOUBLE_QUOTE_OR_SLASH);\n    } else if (p == PEEKED_SINGLE_QUOTED) {\n      peekedString = nextQuotedValue(SINGLE_QUOTE_OR_SLASH);\n    } else if (p == PEEKED_UNQUOTED) {\n      peekedString = nextUnquotedValue();\n    } else if (p != PEEKED_BUFFERED) {\n      throw new JsonDataException(\"Expected a double but was \" + peek() + \" at path \" + getPath());\n    }\n\n    peeked = PEEKED_BUFFERED;\n    double result;\n    try {\n      result = Double.parseDouble(peekedString);\n    } catch (NumberFormatException e) {\n      throw new JsonDataException(\"Expected a double but was \" + peekedString\n          + \" at path \" + getPath());\n    }\n    if (!lenient && (Double.isNaN(result) || Double.isInfinite(result))) {\n      throw new JsonEncodingException(\"JSON forbids NaN and infinities: \" + result\n          + \" at path \" + getPath());\n    }\n    peekedString = null;\n    peeked = PEEKED_NONE;\n    pathIndices[stackSize - 1]++;\n    return result;","sourceCodeStart":660,"sourceCodeEnd":696,"githubUrl":"https://github.com/airbnb/lottie-android/blob/05ea92e90381eb8a8ae06855ea2b74f322bebbec/lottie/src/main/java/com/airbnb/lottie/parser/moshi/JsonUtf8Reader.java#L660-L696","documentation":"JsonUtf8Reader.nextDouble() peeks the next token expecting a numeric value (PEEKED_LONG, PEEKED_NUMBER) or a string that can be parsed as a double (double-quoted, single-quoted, unquoted, buffered). If the token is none of these (boolean, null, object/array start, EOF), it throws JsonDataException. A second throw occurs inside the method if the string-to-double parse fails (NumberFormatException) or if the result is NaN/Infinity in non-lenient mode. This fires when a numeric property in the Lottie JSON has an invalid or wrong-typed value.","triggerScenarios":"A property expected to be a number (opacity, rotation, scale, time offset, etc.) is a boolean, null, object, or array. Or, the value is a string that cannot be parsed as a double (e.g., \"abc\"). Or, the value is NaN/Infinity in strict mode. Each triggers a different variant of the same exception message.","commonSituations":"Malformed Lottie JSON with wrong-typed numeric fields; animation exported with string-encoded numbers that aren't parseable; corrupted file causing token type mismatch; edge case with NaN/Infinity in numeric literals.","solutions":["Use the exception path to locate the field and ensure it contains a valid JSON number.","If the field is a string-encoded number, ensure it's parseable as Double.parseDouble().","Re-export or re-download the animation to fix corrupted data."],"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 numeric type error */ });","preventionTips":["Ensure numeric fields in Lottie JSON are valid JSON numbers.","Validate with LottieFiles validator.","Use async LottieCompositionFactory APIs for graceful error handling."],"tags":["lottie","json-parsing","type-mismatch","double","json-data-exception"],"backgroundTag":null,"analyzedSha":"05ea92e90381eb8a8ae06855ea2b74f322bebbec","analyzedAt":"2026-08-14T00:51:35.636Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}